|
| 1 | +name: "auto-readme" |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + |
| 5 | + schedule: |
| 6 | + # Example of job definition: |
| 7 | + # .---------------- minute (0 - 59) |
| 8 | + # | .------------- hour (0 - 23) |
| 9 | + # | | .---------- day of month (1 - 31) |
| 10 | + # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... |
| 11 | + # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat |
| 12 | + # | | | | | |
| 13 | + # * * * * * user-name command to be executed |
| 14 | + |
| 15 | + # Update README.md nightly at 4am UTC |
| 16 | + - cron: '0 4 * * *' |
| 17 | + |
| 18 | +jobs: |
| 19 | + update: |
| 20 | + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Find default branch name |
| 26 | + id: defaultBranch |
| 27 | + shell: bash |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 30 | + run: | |
| 31 | + default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name) |
| 32 | + printf "::set-output name=defaultBranch::%s\n" "${default_branch}" |
| 33 | + printf "defaultBranchRef.name=%s\n" "${default_branch}" |
| 34 | +
|
| 35 | + - name: Update readme |
| 36 | + shell: bash |
| 37 | + id: update |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 40 | + DEF: "${{ steps.defaultBranch.outputs.defaultBranch }}" |
| 41 | + run: | |
| 42 | + make init |
| 43 | + make readme/build |
| 44 | + # Ignore changes if they are only whitespace |
| 45 | + if ! git diff --quiet README.md && git diff --ignore-all-space --ignore-blank-lines --quiet README.md; then |
| 46 | + git restore README.md |
| 47 | + echo Ignoring whitespace-only changes in README |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Create Pull Request |
| 51 | + # This action will not create or change a pull request if there are no changes to make. |
| 52 | + # If a PR of the auto-update/readme branch is open, this action will just update it, not create a new PR. |
| 53 | + uses: cloudposse/actions/github/[email protected] |
| 54 | + with: |
| 55 | + token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} |
| 56 | + commit-message: Update README.md and docs |
| 57 | + title: Update README.md and docs |
| 58 | + body: |- |
| 59 | + ## what |
| 60 | + This is an auto-generated PR that updates the README.md and docs |
| 61 | +
|
| 62 | + ## why |
| 63 | + To have most recent changes of README.md and doc from origin templates |
| 64 | +
|
| 65 | + branch: auto-update/readme |
| 66 | + base: ${{ steps.defaultBranch.outputs.defaultBranch }} |
| 67 | + delete-branch: true |
| 68 | + labels: | |
| 69 | + auto-update |
| 70 | + no-release |
| 71 | + readme |
0 commit comments