ref: https://github.com/guitarrapc/githubactions-lab/blob/main/.github/workflows/README-embed-code.yaml
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: README embed-code | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: ["main"] | |
jobs: | |
embed-code: | |
runs-on: ubuntu-latest | |
timeout-minutes: 3 | |
steps: | |
- if: ${{ github.event_name == 'pull_request' }} | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit instead of merge commit | |
- if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: actions/checkout@v3 | |
- name: Embedding Code into README | |
run: | | |
npm install -g embedme | |
embedme README.md | |
- name: git diff | |
id: diff | |
run: | | |
git add -N . | |
git diff --name-only --exit-code | |
continue-on-error: true | |
- if: steps.diff.outcome == 'failure' | |
name: git-commit | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git add . | |
git commit -m "[auto commit] Embed code" | |
- if: steps.diff.outcome == 'failure' | |
name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.head_ref }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment