Skip to content

Commit

Permalink
[2.9] generate token for gh uploads (rancher#47324)
Browse files Browse the repository at this point in the history
* generate token

* update permissions
  • Loading branch information
tashima42 authored Oct 1, 2024
1 parent 0c3e35f commit 40bac83
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ jobs:
if: github.event_name == 'push' && contains(github.ref, 'tags/') # Only run on tags
runs-on: runs-on,runner=2cpu-linux-x64,image=ubuntu22-full-x64,run-id=${{ github.run_id }}
permissions:
contents: read
contents: write
id-token: write
env:
REGISTRY: ""
Expand Down Expand Up @@ -571,9 +571,21 @@ jobs:
run: |
rm -rf dist && mkdir dist
mv $HOME/bin/rancher-rke-k8s-versions.txt ./bin
- name: Read App Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
- name: Create App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.PRIVATE_KEY }}
- name: Generate sha256sum file and upload artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
shell: bash
run: |
set -ex
Expand Down Expand Up @@ -604,7 +616,7 @@ jobs:
gh release upload -R ${{ env.REPOSITORY_OWNER }}/rancher ${{ env.TAG }} ./dist/* --clobber
- name: Add release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
NOTES=$(cat ./dist/rancher-components.txt)
gh release edit -R ${{ github.repository }} ${{ env.TAG }} --notes "$NOTES"
Expand All @@ -613,6 +625,9 @@ jobs:
runs-on: org-${{ github.repository_owner_id }}-amd64-k8s
container: registry.suse.com/bci/bci-base:latest
needs: [create-images-files, merge-agent-manifest, merge-server-manifest]
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -645,9 +660,21 @@ jobs:
export WINDOWS_IMAGES_URL=https://github.com/${{ github.repository }}/releases/download/${{ env.TAG }}/rancher-windows-images.txt
release generate rancher docker-images-digests --config "{}" --registry "${{ env.REGISTRY }}" --images-url "${WINDOWS_IMAGES_URL}" --output-file "${{ env.WINDOWS_2019_FILE }}"
cp "${{ env.WINDOWS_2019_FILE }}" "${{ env.WINDOWS_2022_FILE }}"
- name: Read App Secrets
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ;
secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY
- name: Create App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.PRIVATE_KEY }}
- name: Upload digests
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release upload -R ${{ env.REPOSITORY_OWNER }}/rancher ${{ env.TAG }} ${{ env.LINUX_AMD64_FILE }} --clobber
gh release upload -R ${{ env.REPOSITORY_OWNER }}/rancher ${{ env.TAG }} ${{ env.LINUX_ARM64_FILE }} --clobber
Expand Down

0 comments on commit 40bac83

Please sign in to comment.