Skip to content

Update Release workflow to generate ghcr images#175

Merged
pramodbindal merged 1 commit into
release-v0.1.xfrom
main
May 5, 2025
Merged

Update Release workflow to generate ghcr images#175
pramodbindal merged 1 commit into
release-v0.1.xfrom
main

Conversation

@pramodbindal
Copy link
Copy Markdown
Member

Changes

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

Release Notes

Signed-off-by: Pramod Bindal <prbindal@redhat.com>
Comment on lines +9 to +69
runs-on: ubuntu-latest
steps:
- name: checkout the source code
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: ^1.23

- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: ko-build/setup-ko@v0.8

- name: build and push container images
run: ./hack/build.sh
env:
KO_PUSH: "true"
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"

- name: generate a build timestamp and sha256sum files
run: |
cd builds
echo `date -u +'%Y%m%d%H%M%S'` > ./build_timestamp.txt
echo `date -u +'%Y-%m-%dT%H:%M:%S%:z'` >> ./build_timestamp.txt
sha256sum *.yaml > ./SHA256SUMS.txt

- name: update release notes and executables
if: startsWith(github.ref, 'refs/tags/') # executes only for new release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
builds/*.yaml
builds/build_timestamp.txt
builds/SHA256SUMS.txt

- name: Update executables for main branch changes
if: startsWith(github.ref, 'refs/heads/main') # executes only for changes in main
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: main-devel
prerelease: true
title: "Development Build - main branch"
files: |
builds/*.yaml
builds/build_timestamp.txt
builds/SHA256SUMS.txt No newline at end of file

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 11 months ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the minimal permissions required for the workflow to function correctly. Based on the steps in the workflow:

  • contents: read is required for checking out the source code and caching Go modules.
  • packages: write is required for Docker login and pushing container images.
  • issues: write and pull-requests: write are not needed, as the workflow does not interact with issues or pull requests.
  • contents: write is required for updating release notes and executables.

The permissions block can be added at the root level of the workflow to apply to all jobs, or it can be added to individual jobs. In this case, adding it at the root level is more concise and appropriate.


Suggested changeset 1
.github/workflows/build_and_publish.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build_and_publish.yaml b/.github/workflows/build_and_publish.yaml
--- a/.github/workflows/build_and_publish.yaml
+++ b/.github/workflows/build_and_publish.yaml
@@ -1,2 +1,5 @@
 name: build and publish
+permissions:
+  contents: read
+  packages: write
 on:
EOF
@@ -1,2 +1,5 @@
name: build and publish
permissions:
contents: read
packages: write
on:
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@pramodbindal pramodbindal merged commit d208d06 into release-v0.1.x May 5, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants