This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple workflow for deploying static content to GitHub Pages | |
name: Deploy static content to Pages | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
paths: | |
- 'Output/**' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
# concurrency: | |
# group: "pages" | |
# cancel-in-progress: true | |
jobs: | |
copy_job: | |
name: Copy my folder | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
#token: ${{ secrets.pat }} | |
- name: Do copy | |
env: | |
SRC_FOLDER_PATH: 'Output' | |
TARGET_BRANCH: 'gh-pages' | |
run: | | |
files=$(find $SRC_FOLDER_PATH -type f) # get the file list | |
git config --global user.name 'GitHub Action' | |
git config --global user.email 'action@github.com' | |
git fetch # fetch branches | |
git checkout $TARGET_BRANCH # checkout to your branch | |
git checkout ${GITHUB_REF##*/} -- $files # copy files from the source branch | |
git add -A | |
git diff-index --quiet HEAD || git commit -am "deploy files" # commit to the repository (ignore if no modification) | |
git push origin $TARGET_BRANCH # push to remote branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment