diff --git a/.github/workflows/custom-domain.yml b/.github/workflows/custom-domain.yml index 0f74dad..5eb5692 100644 --- a/.github/workflows/custom-domain.yml +++ b/.github/workflows/custom-domain.yml @@ -30,10 +30,32 @@ jobs: - name: Ensure CNAME file exists run: | echo "lemonademap.com" > CNAME + + # Create or update index.html if it doesn't exist + if [ ! -f "index.html" ]; then + cat << 'EOF' > index.html + + + + + Redirecting to Lemonade Map + + + + +

+ If you are not redirected automatically, follow this + link to the Lemonade Map application. +

+ + +EOF + fi + git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" - git add CNAME - git commit -m "Update CNAME file for custom domain" || echo "No changes to commit" + git add CNAME index.html + git commit -m "Update GitHub Pages configuration files" || echo "No changes to commit" git push - name: Update GitHub Pages settings diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e906a32..999c5c4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -103,6 +103,9 @@ jobs: - name: Ensure CNAME file exists in gh-pages branch run: | + # Create CNAME file in the dist directory before deployment + echo "lemonademap.com" > lemonade-map/dist/CNAME + # Clone the gh-pages branch git clone --single-branch --branch gh-pages https://github.com/${{ github.repository }} gh-pages-temp cd gh-pages-temp @@ -110,11 +113,32 @@ jobs: # Create or update CNAME file echo "lemonademap.com" > CNAME + # Create or update index.html if it doesn't exist + if [ ! -f "index.html" ]; then + cat << 'EOF' > index.html + + + + + Redirecting to Lemonade Map + + + + +

+ If you are not redirected automatically, follow this + link to the Lemonade Map application. +

+ + +EOF + fi + # Commit and push changes git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" - git add CNAME - git commit -m "Update CNAME file for custom domain" || echo "No changes to commit" + git add CNAME index.html + git commit -m "Update GitHub Pages configuration files" || echo "No changes to commit" git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages - name: Verify GitHub Pages Configuration diff --git a/.github/workflows/gh-pages-config.yml b/.github/workflows/gh-pages-config.yml index 1d351fc..1bf8129 100644 --- a/.github/workflows/gh-pages-config.yml +++ b/.github/workflows/gh-pages-config.yml @@ -6,15 +6,25 @@ on: branches: - gh-pages +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: write + pages: write + id-token: write + jobs: configure-pages: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: gh-pages - name: Setup Pages uses: actions/configure-pages@v4 + with: + enablement: true # Verify index.html exists at the root - name: Verify index.html @@ -27,6 +37,7 @@ jobs: Redirecting to Lemonade Map + @@ -43,4 +54,13 @@ EOF - name: Verify CNAME file run: | echo "lemonademap.com" > CNAME - echo "Created CNAME file with domain: lemonademap.com" \ No newline at end of file + echo "Created CNAME file with domain: lemonademap.com" + + # Commit changes if any were made + - name: Commit changes + run: | + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git add index.html CNAME + git commit -m "Update GitHub Pages configuration files" || echo "No changes to commit" + git push \ No newline at end of file diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 4e498b2..09913cb 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -42,12 +42,32 @@ jobs: npm run build # Copy the root index.html redirect file to the dist directory - - name: Ensure correct index.html + - name: Ensure correct files run: | # Make sure the dist directory exists mkdir -p lemonade-map/dist # Copy 404.html to the root of the dist directory cp lemonade-map/public/404.html lemonade-map/dist/ + # Create CNAME file in the dist directory + echo "lemonademap.com" > lemonade-map/dist/CNAME + # Create root index.html for redirection + cat << 'EOF' > lemonade-map/dist/index.html + + + + + Redirecting to Lemonade Map + + + + +

+ If you are not redirected automatically, follow this + link to the Lemonade Map application. +

+ + +EOF - name: Setup Pages uses: actions/configure-pages@v4 diff --git a/index.html b/index.html index e13de0a..6beb42f 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ Redirecting to Lemonade Map + diff --git a/lemonade-map/dist/CNAME b/lemonade-map/dist/CNAME index 1c32f9c..44484d4 100644 --- a/lemonade-map/dist/CNAME +++ b/lemonade-map/dist/CNAME @@ -1 +1 @@ -lemonade-map.example.com \ No newline at end of file +lemonademap.com \ No newline at end of file