Skip to content

Commit

Permalink
fix(attach-artifact-release.yml): update GitHub token to use BOT_TOKE…
Browse files Browse the repository at this point in the history
…N instead of GITHUB_TOKEN for API authentication

feat(attach-artifact-release.yml): add support for storing previous release body as an artifact
feat(attach-artifact-release.yml): update dependencies installation step
feat(attach-artifact-release.yml): update upload actions to use BOT_TOKEN for authentication
feat(attach-artifact-release.yml): add step to get latest release ID using BOT_TOKEN for authentication
feat(attach-artifact-release.yml): update Edit Release action to use BOT_TOKEN for authentication
  • Loading branch information
jandroav committed Dec 10, 2023
1 parent 9e0a79a commit 8e00975
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/attach-artifact-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:

- name: Backup release body
run: |
release_id=$(curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases?per_page=1 | jq -r '.[] | select(.name == "${{ env.artifact_id }}") | .id')
release_id=$(curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases?per_page=1 | jq -r '.[] | select(.name == "${{ env.artifact_id }}") | .id')
# Check if release_id is empty
if [ -z "$release_id" ]; then
echo "Release '$release_name' not found in the repository '$repo'."
exit 1
fi
release_url="https://api.github.com/repos/${{ github.repository }}/releases/$release_id"
curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$release_url" | jq -r .body > release_body.txt
curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "$release_url" | jq -r .body > release_body.txt
- name: Store previous release body as artifact
uses: actions/upload-artifact@v2
Expand All @@ -47,7 +47,7 @@ jobs:
uses: dev-drprasad/[email protected]
with:
tag_name: ${{ env.artifact_id }}
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.BOT_TOKEN }}
delete_release: true

- name: Install dependencies
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Upload Windows binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.BOT_TOKEN }}
file: vtrain_windows.zip
asset_name: vtrain_windows_$tag.zip
tag: ${{ env.artifact_id }}
Expand All @@ -70,7 +70,7 @@ jobs:
- name: Upload Linux binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.BOT_TOKEN }}
file: vtrain_linux.zip
asset_name: vtrain_linux_$tag.zip
tag: ${{ env.artifact_id }}
Expand All @@ -79,7 +79,7 @@ jobs:
- name: Upload macOS Silicon binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.BOT_TOKEN }}
file: vtrain_mac_arm.zip
asset_name: vtrain_mac_arm_$tag.zip
tag: ${{ env.artifact_id }}
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Upload macOS Intel binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.BOT_TOKEN }}
file: vtrain_mac_intel.zip
asset_name: vtrain_mac_intel_$tag.zip
tag: ${{ env.artifact_id }}
Expand All @@ -97,14 +97,14 @@ jobs:
- name: Get latest release ID
id: get-release
run: |
LATEST_RELEASE=$(curl -X GET -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=1" | jq -r '.[].id')
LATEST_RELEASE=$(curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=1" | jq -r '.[].id')
echo "Latest Release ID: $LATEST_RELEASE"
echo "RELEASE_ID=$LATEST_RELEASE" >> $GITHUB_ENV
- name: Edit Release
uses: irongut/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.BOT_TOKEN }}
id: ${{ env.RELEASE_ID }}
name: ${{ env.artifact_id }}
replacename: true

0 comments on commit 8e00975

Please sign in to comment.