|
1 | 1 | name: "auto-readme" |
2 | 2 | on: |
| 3 | + workflow_dispatch: |
| 4 | + |
3 | 5 | schedule: |
4 | | - # Update README.md nightly |
| 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 |
5 | 16 | - cron: '0 4 * * *' |
6 | 17 |
|
7 | 18 | jobs: |
8 | 19 | update: |
9 | | - if: github.event_name == 'schedule' |
| 20 | + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' |
10 | 21 | runs-on: ubuntu-latest |
11 | 22 | steps: |
12 | 23 | - uses: actions/checkout@v2 |
13 | 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 | +
|
14 | 35 | - name: Update readme |
15 | 36 | shell: bash |
16 | 37 | id: update |
17 | 38 | env: |
18 | 39 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 40 | + DEF: "${{ steps.defaultBranch.outputs.defaultBranch }}" |
19 | 41 | run: | |
20 | 42 | make init |
21 | 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 |
22 | 49 |
|
23 | 50 | - name: Create Pull Request |
24 | | - uses: cloudposse/actions/github/create-pull-request@0.20.0 |
| 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/create-pull-request@0.30.0 |
25 | 54 | with: |
26 | 55 | token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} |
27 | 56 | commit-message: Update README.md and docs |
|
34 | 63 | To have most recent changes of README.md and doc from origin templates |
35 | 64 |
|
36 | 65 | branch: auto-update/readme |
37 | | - base: master |
| 66 | + base: ${{ steps.defaultBranch.outputs.defaultBranch }} |
38 | 67 | delete-branch: true |
39 | 68 | labels: | |
40 | 69 | auto-update |
| 70 | + no-release |
41 | 71 | readme |
0 commit comments