diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55f0c48a..5961e312 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,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