diff --git a/.github/workflows/cd_pipeline.yml b/.github/workflows/cd_pipeline.yml index f649d08..9dc01b0 100644 --- a/.github/workflows/cd_pipeline.yml +++ b/.github/workflows/cd_pipeline.yml @@ -11,8 +11,7 @@ on: types: - completed workflow_call: -permissions: - contents: write + jobs: deploy: runs-on: ubuntu-latest @@ -26,7 +25,7 @@ jobs: fetch-depth: 0 # Ensure detached HEAD state to avoid conflicts with the main branch ref: refs/heads/main - + - name: Download a Build Artifact Version uses: dawidd6/action-download-artifact@v2.26.1 with: @@ -58,49 +57,14 @@ jobs: name: build path: ./build/ - - - name: List contents of the build directory - run: | - echo "Contents of the build directory:" - ls -al ./build/ - - - name: Configure git + - name: Create and switch to a temporary deployment branch run: | - git config --global user.name ' github-actions[bot]' - git config --global user.email ' github-actions[bot]@users.noreply.github.com' + git checkout -b temp-deploy-branch-$VERSION - - name: Clone GitHub Pages repository - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.SECRET_TO_PUSH_TO_CIROH_GITHUB_IO }} - run: | - git clone --single-branch --branch main https://ciroh-ua:${{ secrets.SECRET_TO_PUSH_TO_CIROH_GITHUB_IO }}@github.com/CIROH-UA/ciroh-ua.github.io.git gh-pages - rsync -av --delete-after ./build/ gh-pages/ # Copy the contents of the build directory - git checkout -b deploy-branch-$VERSION - git add . - git commit -m "Deploy from CI workflow artifact" - - - name: Push changes to new branch - working-directory: gh-pages - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets._PAT_SECRET }} - run: | - git remote add target https://github.com/CIROH-UA/ciroh-ua.github.io.git - git push --set-upstream target deploy-branch-$VERSION - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4.4.0 with: token: ${{ secrets.SECRET_TO_PUSH_TO_CIROH_GITHUB_IO }} - commit-message: "Deploy from CI workflow artifact" - branch: deploy-branch-$VERSION - title: "Deploy from CI" - body: "This is an automated PR to deploy changes from CI workflow." - base: main - - # - name: Commit and push changes - # working-directory: gh-pages - # run: | - # git add . - # git commit -m "Deploy from CI workflow artifact" || echo "Nothing to commit" - # git push --set-upstream origin main - + branch: main + folder: build + repository-name: CIROH-UA/ciroh-ua.github.io