Skip to content

Commit d16e9ce

Browse files
fix(ci): auth actions/checkout as bot because it is used for subsequent ops [MEC-2423] (#2418)
* fix(ci): auth actions/checkout as bot because it is used for subsequent ops [MEC-2423] --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 22890e5 commit d16e9ce

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

.github/workflows/release.yaml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ jobs:
2121
actions: read
2222

2323
steps:
24-
- name: Checkout code
25-
uses: actions/checkout@v6
26-
with:
27-
fetch-depth: 0
28-
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
2924
- name: Retrieve Secrets from Vault
3025
id: vault
3126
uses: hashicorp/vault-action@v3.4.0
@@ -41,16 +36,30 @@ jobs:
4136
secret/data/github/automation-app-user GH_USER_NAME | GIT_COMMITTER_NAME ;
4237
secret/data/github/automation-app-user GH_USER_EMAIL | GIT_COMMITTER_EMAIL ;
4338
44-
# - name: Get Automation Bot User ID
45-
# id: get-user-id
46-
# run: echo "user-id=$(gh api "/users/contentful-automation[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
47-
# env:
48-
# GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
39+
- name: Checkout code
40+
uses: actions/checkout@v6
41+
with:
42+
fetch-depth: 0
43+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
44+
token: ${{ steps.vault.outputs.GITHUB_TOKEN }}
45+
46+
- name: Get Automation Bot User ID
47+
id: get-user-id
48+
run: |
49+
USER_ID=$(gh api "/users/contentful-automation[bot]" --jq .id)
50+
if [ -z "$USER_ID" ] || [ "$USER_ID" = "null" ]; then
51+
echo "Error: Failed to retrieve bot user ID"
52+
exit 1
53+
fi
54+
echo "user-id=$USER_ID" >> "$GITHUB_OUTPUT"
55+
env:
56+
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
57+
58+
- name: Setting up Git User Credentials
59+
run: |
60+
git config --global user.name 'contentful-automation[bot]'
61+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+contentful-automation[bot]@users.noreply.github.com'
4962
50-
# - name: Setting up Git User Credentials
51-
# run: |
52-
# git config --global user.name 'contentful-automation[bot]'
53-
# git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+contentful-automation[bot]@users.noreply.github.com'
5463
- name: Setup npmrc for publishing
5564
run: |
5665
echo "//npm.pkg.github.com/:_authToken=${{ steps.vault.outputs.GITHUB_PACKAGES_WRITE_TOKEN }}" > .npmrc

0 commit comments

Comments
 (0)