Skip to content

Commit 9498d0a

Browse files
Create app-token and use instead of GH_PAT (#4219)
* Create app-token and use instead of GH_PAT * Remove docs for GH_PAT * Fix table alignment
1 parent 3aa39a2 commit 9498d0a

File tree

6 files changed

+63
-24
lines changed

6 files changed

+63
-24
lines changed

.github/workflows/api-docs-repo.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
contents: read
1616
packages: read
1717
steps:
18+
- name: Create token
19+
uses: actions/create-github-app-token@v1
20+
id: app-token
21+
with:
22+
# required
23+
app-id: ${{ secrets.AUTOMATION_ID }}
24+
private-key: ${{ secrets.AUTOMATION_KEY }}
25+
1826
- name: Checkout code
1927
uses: actions/checkout@v3
2028
with:
@@ -23,7 +31,7 @@ jobs:
2331
- name: Create Branch
2432
uses: peterjgrainger/action-create-branch@v2.4.0 # Pinned to v2.4.0
2533
env:
26-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
34+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
2735
with:
2836
branch: ${{ format('bot/update-api-docs-{0}', github.run_number) }}
2937

@@ -87,7 +95,7 @@ jobs:
8795
- name: Create Pull Request
8896
uses: peter-evans/create-pull-request@v5.0.0
8997
with:
90-
token: ${{ secrets.GH_PAT }}
98+
token: ${{ steps.app-token.outputs.token }}
9199
commit-message: Update API Docs
92100
branch: ${{ format('bot/update-api-docs-{0}', github.run_number) }}
93101
base: main

.github/workflows/deploy-site.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ jobs:
1313
packages: read
1414

1515
steps:
16+
- name: Create token
17+
uses: actions/create-github-app-token@v1
18+
id: app-token
19+
with:
20+
# required
21+
app-id: ${{ secrets.AUTOMATION_ID }}
22+
private-key: ${{ secrets.AUTOMATION_KEY }}
23+
1624
- name: Checkout code
1725
uses: actions/checkout@v3
1826
with:
@@ -62,5 +70,5 @@ jobs:
6270
uses: JamesIves/github-pages-deploy-action@v4.4.1 # pinned version
6371
with:
6472
branch: gh-pages
65-
token: ${{ secrets.GH_PAT }}
73+
token: ${{ steps.app-token.outputs.token }}
6674
folder: docs/hugo/public

.github/workflows/helm-chart-repo.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424
packages: read
2525

2626
steps:
27+
- name: Create token
28+
uses: actions/create-github-app-token@v1
29+
id: app-token
30+
with:
31+
# required
32+
app-id: ${{ secrets.AUTOMATION_ID }}
33+
private-key: ${{ secrets.AUTOMATION_KEY }}
34+
2735
- name: Checkout code
2836
uses: actions/checkout@v3
2937
with:
@@ -38,7 +46,7 @@ jobs:
3846
- name: Create Branch
3947
uses: peterjgrainger/action-create-branch@v2.4.0 # Pinned to v2.4.0
4048
env:
41-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
49+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
4250
with:
4351
branch: ${{ format('bot/update-helm-chart-{0}', env.ref) }}
4452
sha: ${{ env.sha }}
@@ -96,7 +104,7 @@ jobs:
96104
- name: Create Pull Request
97105
uses: peter-evans/create-pull-request@v5.0.0
98106
with:
99-
token: ${{ secrets.GH_PAT }}
107+
token: ${{ steps.app-token.outputs.token }}
100108
commit-message: Add Helm Chart
101109
branch: ${{ format('bot/update-helm-chart-{0}', env.ref) }}
102110
base: main

.github/workflows/ok-to-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ jobs:
1414
# Only run for PRs, not issue comments
1515
if: ${{ github.event.issue.pull_request }}
1616
steps:
17+
- name: Create token
18+
uses: actions/create-github-app-token@v1
19+
id: app-token
20+
with:
21+
# required
22+
app-id: ${{ secrets.AUTOMATION_ID }}
23+
private-key: ${{ secrets.AUTOMATION_KEY }}
24+
1725
- name: Slash Command Dispatch
1826
uses: peter-evans/slash-command-dispatch@v4
1927
with:
20-
token: ${{ secrets.GH_PAT }}
28+
token: ${{ steps.app-token.outputs.token }}
2129
reaction-token: ${{ secrets.GITHUB_TOKEN }}
2230
issue-type: pull-request
2331
commands: ok-to-test

.github/workflows/visualize-repo.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ jobs:
1313
permissions:
1414
contents: read
1515
steps:
16+
- name: Create token
17+
uses: actions/create-github-app-token@v1
18+
id: app-token
19+
with:
20+
# required
21+
app-id: ${{ secrets.AUTOMATION_ID }}
22+
private-key: ${{ secrets.AUTOMATION_KEY }}
23+
1624
- name: Checkout code
1725
uses: actions/checkout@v3.3.0
1826
with:
@@ -21,7 +29,7 @@ jobs:
2129
- name: Create Branch
2230
uses: peterjgrainger/action-create-branch@v2.4.0 # Pinned to v2.4.0
2331
env:
24-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
32+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
2533
with:
2634
branch: "bot/update-diagrams"
2735

@@ -69,7 +77,7 @@ jobs:
6977
- name: Create Pull Request
7078
uses: peter-evans/create-pull-request@v5.0.0
7179
with:
72-
token: ${{ secrets.GH_PAT }}
80+
token: ${{ steps.app-token.outputs.token }}
7381
commit-message: Update Code Structure Diagrams
7482
branch: bot/update-diagrams
7583
base: main

docs/hugo/content/contributing/testing.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,31 @@ Basic use: run `task controller:test-integration-envtest`.
1313
| AZURE_SUBSCRIPTION_ID | The Azure Subscription ID | Yes | Yes (when recording) |
1414
| AZURE_TENANT_ID | The Azure Tenant ID | Yes | Yes (when recording) |
1515
| TEST_BILLING_ID | The Azure billing ID | No | Yes (when recording SubscriptionAlias tests) |
16-
| CODECOV_TOKEN | The token to https://app.codecov.io/gh/Azure/azure-service-operator | Yes | No |
17-
| GH_PAT | GitHub PAT, used for PR automation | Yes | No |
16+
| CODECOV_TOKEN | The token to <https://app.codecov.io/gh/Azure/azure-service-operator> | Yes | No |
1817
| REGISTRY_LOGIN | The Azure Container Registry to log in to (for az acr login --name {name}) | Yes | No |
1918
| REGISTRY_PRERELEASE | The path to the container prerelease registry (right now this isn't used) | No | No |
2019
| REGISTRY_PUBLIC | The path to the container release registry, used in --tag "{REGISTRY_PUBLIC}/{CONTROLLER_DOCKER_IMAGE}" | No | No |
2120

22-
2321
### Record/replay
2422

25-
The task `controller:test-integration-envtest` runs the tests in a record/replay mode by default, so that it does not
26-
touch any live Azure resources. (This uses the [go-vcr](https://github.com/dnaeon/go-vcr) library.) If you change the controller or other code in
23+
The task `controller:test-integration-envtest` runs the tests in a record/replay mode by default, so that it does not
24+
touch any live Azure resources. (This uses the [go-vcr](https://github.com/dnaeon/go-vcr) library.) If you change the controller or other code in
2725
such a way that the required requests/responses from ARM change, you will need to update the recordings.
2826

29-
To do this, delete the recordings for the failing tests (under `{test-dir}/recordings/{test-name}.yaml`), and re-run
30-
`controller:test-integration-envtest`. If the test passes, a new recording will be saved, which you can commit to
27+
To do this, delete the recordings for the failing tests (under `{test-dir}/recordings/{test-name}.yaml`), and re-run
28+
`controller:test-integration-envtest`. If the test passes, a new recording will be saved, which you can commit to
3129
include with your change. All authentication and subscription information is removed from the recording.
3230

33-
To run the test and produce a new recording you will need to have set the required authentication environment variables
34-
`AZURE_SUBSCRIPTION_ID` and `AZURE_TENANT_ID`, _and_ logged in via `az login` (or you just use the `task` commands
35-
mentioned below and it will prompt you to `az login` if needed for that specific command).
31+
To run the test and produce a new recording you will need to have set the required authentication environment variables
32+
`AZURE_SUBSCRIPTION_ID` and `AZURE_TENANT_ID`, _and_ logged in via `az login` (or you just use the `task` commands
33+
mentioned below and it will prompt you to `az login` if needed for that specific command).
3634
Note that you must be `Owner` on the subscription to execute some tests in record mode.
3735

38-
A few tests also need the `TEST_BILLING_ID` environment variable set to a valid Azure Billing ID when running in record mode.
39-
In replay mode this variable is never required. Note that the billing ID is redacted from all recording files so that
36+
A few tests also need the `TEST_BILLING_ID` environment variable set to a valid Azure Billing ID when running in record mode.
37+
In replay mode this variable is never required. Note that the billing ID is redacted from all recording files so that
4038
the resulting file can be replayed by anybody, even somebody who does not know the Billing ID the test was recorded with.
4139

42-
Some Azure resources take longer to provision or delete than the default test timeout of 15m. To change the timeout,
40+
Some Azure resources take longer to provision or delete than the default test timeout of 15m. To change the timeout,
4341
set `TIMEOUT` to a suitable value when running task. For example, to give your test a 60m timeout, use:
4442

4543
``` bash
@@ -48,12 +46,13 @@ TIMEOUT=60m task controller:test-integration-envtest
4846

4947
### Running live tests
5048

51-
If you want to skip all recordings and run all tests directly against live Azure resources, you can use the
52-
`controller:test-integration-envtest-live` task. This will also require you to set the authentication environment
49+
If you want to skip all recordings and run all tests directly against live Azure resources, you can use the
50+
`controller:test-integration-envtest-live` task. This will also require you to set the authentication environment
5351
variables and `az login`, as detailed above.
5452

5553
### Running a single test
56-
By default `task controller:test-integration-envtest` and its variants run all tests. This is often undesirable
54+
55+
By default `task controller:test-integration-envtest` and its variants run all tests. This is often undesirable
5756
as you may just be working on a single feature or test. In order to run a subset of tests, use the `TEST_FILTER`:
5857

5958
```bash

0 commit comments

Comments
 (0)