[CONTENT] Error handling #3
Workflow file for this run
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
name: Generate Image Preview | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
paths: | |
- 'content/**' | |
# cancel in-progress runs on new commits to same PR (github.event.number) | |
concurrency: | |
group: gen_preview_image${{ github.workflow }}-${{ github.event.number || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
generate-preview: | |
runs-on: ubuntu-latest | |
name: Generate Preview Image | |
permissions: # Job-level permissions configuration starts here | |
contents: write # 'write' access to repository contents | |
pull-requests: write # 'write' access to pull requests | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
# Download bin of gen_preview | |
- name: Install preview bin | |
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/RustLangES/rustmap/releases/download/v0.2.0/preview-installer.sh | sh | |
- name: Get changed files | |
run: | | |
files=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD main)) | |
preview ./crates/preview/assets/bg_preview.png ./public/previews $files | |
- name: Commit changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add -A | |
git commit -m "chore: generate opengraph image" || echo "No changes to commit" | |
- uses: ad-m/github-push-action@master | |
with: | |
branch: ${{ github.head_ref }} | |