Skip to content

Commit 9b4220a

Browse files
authored
Add workflow permissions and clean up things (#25)
1 parent 80756ce commit 9b4220a

File tree

5 files changed

+82
-58
lines changed

5 files changed

+82
-58
lines changed

.github/workflows/release.yml

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,75 +14,85 @@
1414

1515
name: 'Pull Request to GitHub'
1616

17-
on: workflow_dispatch
17+
on: 'workflow_dispatch'
1818

1919
env:
20-
PR_BRANCH: 'google-github-actions/update-${{github.sha}}'
20+
PR_BRANCH: 'google-github-actions/update-${{ github.sha }}'
21+
22+
permissions:
23+
contents: 'read'
24+
statuses: 'write'
25+
26+
defaults:
27+
run:
28+
shell: 'bash'
2129

2230
jobs:
2331
pull-request:
24-
runs-on: ubuntu-latest
32+
runs-on: 'ubuntu-latest'
2533
steps:
2634
- name: 'Checkout'
27-
uses: actions/checkout@v3
35+
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
2836
with:
2937
path: ./example-workflows
3038

3139
- name: 'Setup go'
32-
uses: actions/setup-go@v3
40+
uses: 'actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5' # ratchet:actions/setup-go@v5
3341
with:
34-
go-version: '^1.17.7'
42+
go-version-file: 'go.mod'
3543

3644
- name: 'Checkout Starter Workflows'
37-
uses: actions/checkout@v3
45+
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
3846
with:
39-
repository: actions/starter-workflows
40-
ref: main
41-
path: ./starter-workflows
47+
repository: 'actions/starter-workflows'
48+
ref: 'main'
49+
path: './starter-workflows'
4250

4351
- name: 'Create New Branch'
44-
working-directory: ./starter-workflows
45-
run: git checkout -b $PR_BRANCH
52+
working-directory: './starter-workflows'
53+
run: |-
54+
git checkout -b "${PR_BRANCH}"
4655
4756
- name: 'Update Files'
48-
working-directory: ./example-workflows
49-
run: go run scripts/release.go
50-
57+
working-directory: './example-workflows'
58+
run: |-
59+
go run ./scripts/release/...
60+
5161
- name: 'Git Status'
52-
working-directory: ./starter-workflows
53-
run: git status
54-
55-
# - name: 'Push Branch to Remote'
56-
# working-directory: ./starter-workflows
57-
# run: git push origin main
58-
59-
# - name: 'Create Pull Request'
60-
# uses: actions/[email protected]
61-
# with:
62-
# script: |
63-
# const output = `
64-
# ## Update Google GitHub Actions Starter Workflows
65-
66-
# ### **NOTE: This is an automated pull request.**
67-
68-
# This pull request was created by the Google GitHub Actions team.
69-
70-
# Please refer to the https://github.com/google-github-actions/example-workflows for more information.
71-
# `;
72-
73-
# const response = await github.rest.pulls.create({
74-
# owner: `actions`,
75-
# repo: `starter-workflows`,
76-
# title: `Update Google GitHub Actions Starter Workflows`,
77-
# head: `${{env.PR_BRANCH}}`,
78-
# base: `main`,
79-
# maintainer_can_modify: true,
80-
# body: output
81-
# });
82-
#
83-
# console.log(`Pull Request #: ${response.number}`)
84-
# console.log(`HTML URL : ${response.html_url}`)
85-
#
86-
# console.log(`Response: `)
87-
# console.log(response)
62+
working-directory: './starter-workflows'
63+
run: |-
64+
git status
65+
66+
# - name: 'Push Branch to Remote'
67+
# working-directory: ./starter-workflows
68+
# run: git push origin main
69+
70+
# - name: 'Create Pull Request'
71+
# uses: actions/[email protected]
72+
# with:
73+
# script: |
74+
# const output = `
75+
# ## Update Google GitHub Actions Starter Workflows
8876

77+
# ### **NOTE: This is an automated pull request.**
78+
79+
# This pull request was created by the Google GitHub Actions team.
80+
81+
# Please refer to the https://github.com/google-github-actions/example-workflows for more information.
82+
# `;
83+
84+
# const response = await github.rest.pulls.create({
85+
# owner: `actions`,
86+
# repo: `starter-workflows`,
87+
# title: `Update Google GitHub Actions Starter Workflows`,
88+
# head: `${{env.PR_BRANCH}}`,
89+
# base: `main`,
90+
# maintainer_can_modify: true,
91+
# body: output
92+
# });
93+
#
94+
# console.log(`Pull Request #: ${response.number}`)
95+
# console.log(`HTML URL : ${response.html_url}`)
96+
#
97+
# console.log(`Response: `)
98+
# console.log(response)

.github/workflows/validate-readme.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,34 @@ name: 'Validate Readme'
1717
on:
1818
push:
1919
branches:
20-
- main
20+
- 'main'
2121
pull_request:
2222
branches:
23-
- main
23+
- 'main'
24+
25+
permissions:
26+
contents: 'read'
27+
statuses: 'write'
28+
29+
defaults:
30+
run:
31+
shell: 'bash'
2432

2533
jobs:
2634
gen-readme:
27-
runs-on: ubuntu-latest
35+
runs-on: 'ubuntu-latest'
2836
steps:
2937
- name: 'Checkout'
30-
uses: actions/checkout@v3
38+
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
3139

3240
- name: 'Setup go'
33-
uses: actions/setup-go@v3
41+
uses: 'actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5' # ratchet:actions/setup-go@v5
3442
with:
35-
go-version: '^1.17.7'
43+
go-version-file: 'go.mod'
3644

3745
- name: 'Generate Readme'
38-
run: go run scripts/generate.go readme
46+
run: |-
47+
go run ./scripts/generate/... readme
3948
4049
- name: 'Validate Diff'
4150
run: |

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/google-github-actions/example-workflows
2+
3+
go 1.24
4+
5+
toolchain go1.24.5
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)