Skip to content

Commit 8e3fbc1

Browse files
authored
Merge pull request #2152 from amustaque97/feat-decouple-actions
feat: setup reusable actions workflow template
2 parents c73249c + e727d65 commit 8e3fbc1

File tree

3 files changed

+108
-73
lines changed

3 files changed

+108
-73
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Generate GitHub App Tokens
2+
description: Generate organization-scoped GitHub tokens using GitHub App credentials
3+
4+
inputs:
5+
app-id:
6+
description: GitHub App ID
7+
required: true
8+
private-key:
9+
description: GitHub App private key
10+
required: true
11+
12+
outputs:
13+
rust-lang-token: ${{ steps.rust-lang-token.outputs.token }}
14+
rust-lang-deprecated-token: ${{ steps.rust-lang-deprecated-token.outputs.token }}
15+
rust-lang-nursery-token: ${{ steps.rust-lang-nursery-token.outputs.token }}
16+
bors-rs-token: ${{ steps.bors-rs-token.outputs.token }}
17+
rust-analyzer-token: ${{ steps.rust-analyzer-token.outputs.token }}
18+
rust-embedded-token: ${{ steps.rust-embedded-token.outputs.token }}
19+
rust-dev-tools-token: ${{ steps.rust-dev-tools-token.outputs.token }}
20+
21+
runs:
22+
using: composite
23+
steps:
24+
# GitHub tokens generated from GitHub Apps can access resources from one organization,
25+
# so we need to generate a token for each organization.
26+
- name: Generate GitHub token (rust-lang)
27+
uses: actions/create-github-app-token@v1
28+
id: rust-lang-token
29+
with:
30+
app-id: ${{ inputs.app-id }}
31+
private-key: ${{ inputs.private-key }}
32+
owner: rust-lang
33+
34+
- name: Generate GitHub token (rust-lang-deprecated)
35+
uses: actions/create-github-app-token@v1
36+
id: rust-lang-deprecated-token
37+
with:
38+
app-id: ${{ inputs.app-id }}
39+
private-key: ${{ inputs.private-key }}
40+
owner: rust-lang-deprecated
41+
42+
- name: Generate GitHub token (rust-lang-nursery)
43+
uses: actions/create-github-app-token@v1
44+
id: rust-lang-nursery-token
45+
with:
46+
app-id: ${{ inputs.app-id }}
47+
private-key: ${{ inputs.private-key }}
48+
owner: rust-lang-nursery
49+
50+
- name: Generate GitHub token (bors-rs)
51+
uses: actions/create-github-app-token@v1
52+
id: bors-rs-token
53+
with:
54+
app-id: ${{ inputs.app-id }}
55+
private-key: ${{ inputs.private-key }}
56+
owner: bors-rs
57+
58+
- name: Generate GitHub token (rust-analyzer)
59+
uses: actions/create-github-app-token@v1
60+
id: rust-analyzer-token
61+
with:
62+
app-id: ${{ inputs.app-id }}
63+
private-key: ${{ inputs.private-key }}
64+
owner: rust-analyzer
65+
66+
- name: Generate GitHub token (rust-embedded)
67+
uses: actions/create-github-app-token@v1
68+
id: rust-embedded-token
69+
with:
70+
app-id: ${{ inputs.app-id }}
71+
private-key: ${{ inputs.private-key }}
72+
owner: rust-embedded
73+
74+
- name: Generate GitHub token (rust-dev-tools)
75+
uses: actions/create-github-app-token@v1
76+
id: rust-dev-tools-token
77+
with:
78+
app-id: ${{ inputs.app-id }}
79+
private-key: ${{ inputs.private-key }}
80+
owner: rust-dev-tools
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Setup Rust
2+
description: Install Rust stable toolchain and setup caching
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install Rust Stable
8+
shell: bash
9+
run: |
10+
rustc -vV
11+
rustup update stable
12+
rustup default stable
13+
rustc -vV
14+
15+
# Pinning a specific version to avoid surprises
16+
- uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844

.github/workflows/dry-run.yml

Lines changed: 12 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,8 @@ jobs:
3838
ref: ${{ github.event.workflow_run.head_repository.full_name != 'rust-lang/team' && 'main' || github.event.workflow_run.head_sha }}
3939
persist-credentials: false
4040

41-
- name: Install Rust Stable
42-
run: |
43-
rustc -vV
44-
rustup update stable
45-
rustup default stable
46-
rustc -vV
47-
48-
# Pinning a specific version to avoid surprises
49-
- uses: Swatinem/rust-cache@27b8ea9368cf428f0bfe41b0876b1a7e809d9844
41+
- name: Setup Rust
42+
uses: ./.github/actions/setup-rust
5043

5144
- name: Download built JSON API
5245
uses: actions/download-artifact@v4
@@ -56,76 +49,22 @@ jobs:
5649
run-id: ${{ github.event.workflow_run.id }}
5750
github-token: ${{ secrets.GITHUB_TOKEN }}
5851

59-
# GitHub tokens generated from GitHub Apps can access resources from one organization,
60-
# so we need to generate a token for each organization.
61-
- name: Generate GitHub token (rust-lang)
62-
uses: actions/create-github-app-token@v1
63-
id: rust-lang-token
64-
with:
65-
# GitHub App ID secret name
66-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
67-
# GitHub App private key secret name
68-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
69-
# Set the owner, so the token can be used in all repositories
70-
owner: rust-lang
71-
72-
- name: Generate GitHub token (rust-lang-deprecated)
73-
uses: actions/create-github-app-token@v1
74-
id: rust-lang-deprecated-token
75-
with:
76-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
77-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
78-
owner: rust-lang-deprecated
79-
80-
- name: Generate GitHub token (rust-lang-nursery)
81-
uses: actions/create-github-app-token@v1
82-
id: rust-lang-nursery-token
83-
with:
84-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
85-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
86-
owner: rust-lang-nursery
87-
88-
- name: Generate GitHub token (bors-rs)
89-
uses: actions/create-github-app-token@v1
90-
id: bors-rs-token
91-
with:
92-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
93-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
94-
owner: bors-rs
95-
96-
- name: Generate GitHub token (rust-analyzer)
97-
uses: actions/create-github-app-token@v1
98-
id: rust-analyzer-token
99-
with:
100-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
101-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
102-
owner: rust-analyzer
103-
104-
- name: Generate GitHub token (rust-embedded)
105-
uses: actions/create-github-app-token@v1
106-
id: rust-embedded-token
107-
with:
108-
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
109-
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
110-
owner: rust-embedded
111-
112-
- name: Generate GitHub token (rust-dev-tools)
113-
uses: actions/create-github-app-token@v1
114-
id: rust-dev-tools-token
52+
- name: Generate GitHub App tokens
53+
uses: ./.github/actions/generate-tokens
54+
id: generate-tokens
11555
with:
11656
app-id: ${{ secrets.SYNC_TEAM_GH_APP_ID }}
11757
private-key: ${{ secrets.SYNC_TEAM_GH_APP_PRIVATE_KEY }}
118-
owner: rust-dev-tools
11958

12059
- name: Run sync-team dry-run check
12160
env:
122-
GITHUB_TOKEN_RUST_LANG: ${{ steps.rust-lang-token.outputs.token }}
123-
GITHUB_TOKEN_RUST_LANG_DEPRECATED: ${{ steps.rust-lang-deprecated-token.outputs.token }}
124-
GITHUB_TOKEN_RUST_LANG_NURSERY: ${{ steps.rust-lang-nursery-token.outputs.token }}
125-
GITHUB_TOKEN_BORS_RS: ${{ steps.bors-rs-token.outputs.token }}
126-
GITHUB_TOKEN_RUST_ANALYZER: ${{ steps.rust-analyzer-token.outputs.token }}
127-
GITHUB_TOKEN_RUST_EMBEDDED: ${{ steps.rust-embedded-token.outputs.token }}
128-
GITHUB_TOKEN_RUST_DEV_TOOLS: ${{ steps.rust-dev-tools-token.outputs.token }}
61+
GITHUB_TOKEN_RUST_LANG: ${{ steps.generate-tokens.outputs.rust-lang-token }}
62+
GITHUB_TOKEN_RUST_LANG_DEPRECATED: ${{ steps.generate-tokens.outputs.rust-lang-deprecated-token }}
63+
GITHUB_TOKEN_RUST_LANG_NURSERY: ${{ steps.generate-tokens.outputs.rust-lang-nursery-token }}
64+
GITHUB_TOKEN_BORS_RS: ${{ steps.generate-tokens.outputs.bors-rs-token }}
65+
GITHUB_TOKEN_RUST_ANALYZER: ${{ steps.generate-tokens.outputs.rust-analyzer-token }}
66+
GITHUB_TOKEN_RUST_EMBEDDED: ${{ steps.generate-tokens.outputs.rust-embedded-token }}
67+
GITHUB_TOKEN_RUST_DEV_TOOLS: ${{ steps.generate-tokens.outputs.rust-dev-tools-token }}
12968
# This applies pipefail, so that the tee pipeline below fails when sync-team fails.
13069
shell: bash
13170
run: |

0 commit comments

Comments
 (0)