Skip to content

Commit bb59a4c

Browse files
authored
Update non-Default GitHub token usage to Mu GitHub app (#430)
Generates tokens during workflow execution instead of directly depending on PATs. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent 4ba64ef commit bb59a4c

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

.github/workflows/FileSyncer.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ jobs:
3030
- name: Checkout Repository
3131
uses: actions/checkout@v4
3232

33+
- name: Generate Token
34+
id: app-token
35+
uses: actions/create-github-app-token@v2
36+
with:
37+
app-id: ${{ vars.MU_ACCESS_APP_ID }}
38+
private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
39+
3340
- name: Run GitHub File Sync
3441
uses: BetaHuhn/repo-file-sync-action@v1
3542
with:
@@ -40,7 +47,7 @@ jobs:
4047
CONFIG_PATH: .sync/Files.yml
4148
DRY_RUN: false
4249
FORK: false
43-
GH_PAT: ${{ secrets.UEFI_BOT_REPO_FILE_SYNC }}
50+
GH_PAT: ${{ steps.app-token.outputs.token }}
4451
GIT_EMAIL: uefibot@microsoft.com
4552
GIT_USERNAME: uefibot
4653
ORIGINAL_MESSAGE: true

.sync/workflows/leaf/backport-to-release-branch.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# This workflow moves marked commits from a development branch to a release branch.
22
#
3+
# This workflow requires a GitHub App with the following permissions:
4+
# - Read and write access to repository contents
5+
# - Read and write access to pull requests
6+
#
7+
# The GitHub App ID and private key should be stored in the repository as a variable named `MU_ACCESS_APP_ID` and a
8+
# secret named `MU_ACCESS_APP_PRIVATE_KEY` respectively.
9+
#
310
# Each commit in the development branch is cherry-picked to the release branch if the commit originates from a merged
411
# PR that is marked for backport.
512
#
@@ -35,11 +42,18 @@ on:
3542
runs-on: ubuntu-latest
3643

3744
steps:
45+
- name: Generate Token
46+
id: app-token
47+
uses: actions/create-github-app-token@v2
48+
with:
49+
app-id: ${{ vars.MU_ACCESS_APP_ID }}
50+
private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
51+
3852
- name: Checkout code
3953
uses: actions/checkout@v4
4054
with:
4155
fetch-depth: 0
42-
token: ${{ secrets.CHERRY_PICK_TOKEN }}
56+
token: ${{ steps.app-token.outputs.token }}
4357

4458
- name: Determine Contribution Info
4559
id: backport_info
@@ -231,5 +245,5 @@ on:
231245
-H "Content-Type: application/json" \
232246
-d "{\"title\":\"$PR_TITLE\",\"body\":\"$PR_BODY\",\"head\":\"$PR_BRANCH\",\"base\":\"$BASE_BRANCH\",\"labels\":[\"type:release-merge-conflict\"]}"
233247
env:
234-
CHERRY_PICK_TOKEN: ${{ secrets.CHERRY_PICK_TOKEN }}
248+
CHERRY_PICK_TOKEN: ${{ steps.app-token.outputs.token }}
235249
{% endraw %}

.sync/workflows/leaf/submodule-release-update.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# This workflow automatically creates a pull request for any submodule in the repo
22
# that has a new GitHub release available. The release must follow semantic versioning.
33
#
4+
# The GitHub App ID and private key should be stored in the repository as a variable named `MU_ACCESS_APP_ID` and a
5+
# secret named `MU_ACCESS_APP_PRIVATE_KEY` respectively.
6+
#
7+
# The GitHub App must grant the following permissions:
8+
# - Read and write access to repository contents
9+
# - Read and write access to pull requests
10+
#
411
# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there
512
# instead of the file in this repo.
613
#
@@ -30,10 +37,17 @@ jobs:
3037
pull-requests: write
3138

3239
steps:
40+
- name: Generate Token
41+
id: app-token
42+
uses: actions/create-github-app-token@v2
43+
with:
44+
app-id: ${{ vars.MU_ACCESS_APP_ID }}
45+
private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
46+
3347
- name: Update Submodules to Latest Release
3448
uses: microsoft/mu_devops/.github/actions/submodule-release-updater@{{ sync_version.mu_devops }}
3549
with:
36-
GH_PAT: {% raw %}${{ secrets.SUBMODULE_UPDATER_TOKEN }}{% endraw %}
50+
GH_PAT: {% raw %}${{ steps.app-token.outputs.token }}{% endraw %}
3751
GH_USER: "ProjectMuBot"
3852
GIT_EMAIL: "mubot@microsoft.com"
3953
GIT_NAME: "Project Mu Bot"

0 commit comments

Comments
 (0)