Skip to content

Update manual_cd.yml #1

Update manual_cd.yml

Update manual_cd.yml #1

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: ciroh-ua-website-cd
on:
workflow_dispatch:
workflow_run:
workflows: ["Build and Upload Artifact"]
types:
- completed
push:
branches:
- 'main'
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy to GitHub Pages
permissions:
deployments: write
contents: write
statuses: write
actions: write
checks: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
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:
workflow: ci_pipeline.yml
workflow_conclusion: success
branch: main
name: version
path: ./
- name: Read file and set variable
run: |
# Read file and set its value to a variable
FILE_CONTENT=$(cat ./version.txt)
# Set variable as an environment variable
echo "VERSION=$FILE_CONTENT" >> $GITHUB_ENV
- name: Display variable value
run: |
# Display value of variable
echo "My variable value is $VERSION and $GITHUB_ENV"
# https://github.com/marketplace/actions/download-workflow-artifact
- name: Download a Build Artifact
uses: dawidd6/[email protected]
with:
workflow: ci_pipeline.yml
workflow_conclusion: success
branch: main
name: build
path: ./build/
- name: List contents of the build directory
run: |
echo "Contents of the build directory:"
ls -al ./build/
- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- 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:${PERSONAL_ACCESS_TOKEN}@github.com/CIROH-UA/ciroh-ua.github.io.git gh-pages
git remote set-url origin https://x-access-token:${PERSONAL_ACCESS_TOKEN}@github.com/CIROH-UA/ciroh-ua.github.io.git
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: Configure authentication
working-directory: gh-pages
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PAT }}
run: |
git remote set-url origin https://x-access-token:${PERSONAL_ACCESS_TOKEN}@github.com/CIROH-UA/ciroh-ua.github.io.git
- name: Push changes to new branch
working-directory: gh-pages
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PAT }}
run: |
git push origin deploy-branch-$VERSION
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v4
# 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