From a6a79f30e4b0abe6c1aaead4b4769e326bf00299 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 2 Nov 2025 11:43:24 +0100 Subject: [PATCH 1/2] trying to make the github action script work for stage and prod branches --- .github/workflows/build-and-deploy.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 9339db7..3a63687 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -3,16 +3,18 @@ name: Build Astro and deploy dist on: push: branches: - - stage # or your default branch + - stage + - prod workflow_dispatch: permissions: - contents: write # 👈 This is required for pushing branches + contents: write # 👈 This is required for pushing branches jobs: build: runs-on: ubuntu-latest - environment: stage + # Dynamically set environment name based on branch + environment: ${{ github.ref_name }} steps: - name: Checkout code @@ -21,7 +23,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '22' # match your project + node-version: "22" # match your project - name: Install dependencies run: npm ci @@ -29,24 +31,24 @@ jobs: - name: Build Astro project run: npm run build - - name: Deploy dist to dist-stage + - name: Deploy dist to dist-${{ env.DIST_BRANCH }} run: | # Configure Git git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - + # Create temporary branch git checkout --orphan temp-build # Clean it git rm -rf . - + # Commit and force push git add dist git branch git commit -m "Update dist/ [skip ci]" - git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Signum/workaround-astro-starlight.git temp-build:dist-stage --force + git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} temp-build:${{ env.DIST_BRANCH }} --force - name: Trigger deployment webhook run: | @@ -54,4 +56,3 @@ jobs: env: DEPLOY_WEBHOOK: ${{ secrets.COOLIFY_DEPLOY_WEBHOOK }} DEPLOY_TOKEN: ${{ secrets.COOLIFY_DEPLOY_TOKEN }} - From 7bb8bc74b788ddd9017f98a75c692173a5a8de30 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 2 Nov 2025 13:19:07 +0100 Subject: [PATCH 2/2] ffs --- .github/workflows/build-and-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 3a63687..6460280 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -31,7 +31,7 @@ jobs: - name: Build Astro project run: npm run build - - name: Deploy dist to dist-${{ env.DIST_BRANCH }} + - name: Deploy dist to dist-${{ github.ref_name }} run: | # Configure Git git config user.name "github-actions[bot]" @@ -48,7 +48,7 @@ jobs: git branch git commit -m "Update dist/ [skip ci]" - git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} temp-build:${{ env.DIST_BRANCH }} --force + git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} temp-build:dist-${{ github.ref_name }} --force - name: Trigger deployment webhook run: |