From 41c7bcdf68f4a3c4f51673730e47885ce6894b5f Mon Sep 17 00:00:00 2001 From: praliptarajoo Date: Tue, 9 Jan 2024 18:40:53 +0530 Subject: [PATCH 1/2] yml updated for new branch create --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55f0c48a..4bb54ba5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,12 @@ jobs: - name: 'Checkout repository' uses: actions/checkout@v2 + - name: 'Create build-run branch' + run: | + git fetch origin + git checkout -b build-run + git push origin build-run + - name: Set up Node.js uses: actions/setup-node@v4 with: From 5ff991f82f413e9d4770a43466adc5a920b9cc43 Mon Sep 17 00:00:00 2001 From: praliptarajoo Date: Wed, 10 Jan 2024 12:11:19 +0530 Subject: [PATCH 2/2] yml updated to resolve protected branch --- .github/workflows/ci.yml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bb54ba5..5961e312 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,6 @@ jobs: - name: 'Checkout repository' uses: actions/checkout@v2 - - name: 'Create build-run branch' - run: | - git fetch origin - git checkout -b build-run - git push origin build-run - - name: Set up Node.js uses: actions/setup-node@v4 with: @@ -34,29 +28,36 @@ jobs: - name: 'Build application' run: npm run build - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actions - message: 'build: build application' - fetch: false + - name: 'Fetch branches' + run: git fetch origin + + - name: 'Set Git user name and email' + run: | + git config --local user.email "github-actions@github.com" + git config --local user.name "GitHub Actions" - - name: Fetch branches and create gh-pages branch + - name: 'Resolve merge conflicts if any' run: | + git checkout main git fetch origin - - - name: Copy to temp-directory + git reset --hard origin/main + + - name: 'Copy build artifacts to gh-pages branch' run: | mkdir /tmp/temp-directory cp -r .next/* /tmp/temp-directory/ git checkout gh-pages git rm -rf . cp -r /tmp/temp-directory/ . - git add temp-directory/ - git commit -m "Copy main-folder to gh-pages branch" - + git add temp-directory/ + git commit -m "Copy build artifacts from main to gh-pages branch" + - name: Push to gh-pages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git push origin gh-pages + + - name: 'Switch back to main branch' + run: | + git checkout main