Skip to content

Commit

Permalink
Updated cd_pipeline.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
arpita0911patel authored May 30, 2024
1 parent e85c1d4 commit 2b2ee1f
Showing 1 changed file with 9 additions and 45 deletions.
54 changes: 9 additions & 45 deletions .github/workflows/cd_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ on:
types:
- completed
workflow_call:
permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -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/[email protected]
with:
Expand Down Expand Up @@ -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/[email protected]
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

0 comments on commit 2b2ee1f

Please sign in to comment.