When trying to run the release pipeline I showed you last Thursday, it originally failed with the following error message:
Error: Resource not accessible by integration
Here is the original Github Actions workflow I was using:
name: release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # Matches tags like v1.0.0, v2.1.3, etc. | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# removed the other steps | |
- name: Archive the output | |
run: | | |
New-Item -Path Client/out/make -ItemType Directory -Force | |
Compress-Archive -Path Client/out/make -DestinationPath ${{ github.workspace }}/output.zip | |
shell: pwsh | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
body: | | |
## Changes | |
- List the changes in this release here. | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}/output.zip | |
asset_name: output.zip | |
asset_content_type: application/zip |
The error above was caused by the fact that the Github Actions workflow couldn’t access the Releases inside Github. There are multiple ways to fix this:
- Create a separate PAT (Personal Access Token) with specific rights needed to create a release
- Override the default permissions in the workflow file itself
- Update the permissions in the Github Actions settings
I decided to go for the second option and updated the workflow file to include the specific permission needed:
jobs: | |
build: | |
runs-on: windows-latest | |
#Required to be able to create a new release | |
permissions: | |
contents: write |
Remark: It can take some time to identify the right permission you need, so certainly check out the documentation or ask Github Copilot for help.
More information
Controlling permissions for GITHUB_TOKEN - GitHub Docs
Github–Create a new release–The automated version (bartwullems.blogspot.com)