-
Notifications
You must be signed in to change notification settings - Fork 43
Updates to container images #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: container-images | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - '**' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| env: | ||
| DOCKER_BUILDX_PLATFORM: linux/amd64 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: set up Docker buildx | ||
| uses: docker/setup-buildx-action@v4 | ||
| with: | ||
| platforms: ${{ env.DOCKER_BUILDX_PLATFORM }} | ||
|
|
||
| - uses: docker/login-action@v4 | ||
| if: ${{ github.event_name == 'push' }} | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: info | ||
| run: | | ||
| docker version | ||
| docker info | ||
|
|
||
| echo '${{ github.ref_name }}' | sed -e 's/[^a-zA-Z0-9._-]/_/g' > VERSION_TAG | ||
| echo "version_tag=$(cat VERSION_TAG)" | ||
|
|
||
| - name: build | ||
| run: | | ||
| docker buildx build \ | ||
| --load \ | ||
| --platform "${DOCKER_BUILDX_PLATFORM}" \ | ||
| \ | ||
| --build-arg "VERSION=${{ github.ref_name }}" \ | ||
| --build-arg "FFMPEG_VERSION=release" \ | ||
| --build-arg "BUILD_DATE=$(date -u +"%Y-%m-%dT%TZ")" \ | ||
| --build-arg "GIT_COMMIT=${{ github.sha }}" \ | ||
| \ | ||
| -t "ghcr.io/opencast/pyca:latest" \ | ||
| -t "ghcr.io/opencast/pyca:main" \ | ||
|
Comment on lines
+54
to
+55
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will create I think that's what these docker Actions take care of: But to be fair, I just copied them from a college who ensured me that this is what I wanted :D
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you said, this only tags images within the build environment. In my CI pipelines, I usually tag images with any potential tag and push if necessary. For this reason, I don't use |
||
| -t "ghcr.io/opencast/pyca:${{ github.sha }}" \ | ||
| -t "ghcr.io/opencast/pyca:$(cat VERSION_TAG)" \ | ||
| . | ||
|
|
||
| - name: push release | ||
| if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | ||
| run: | | ||
| docker push "ghcr.io/opencast/pyca:$(cat VERSION_TAG)" | ||
| # assumption: last tag is always latest version | ||
| docker push "ghcr.io/opencast/pyca:latest" | ||
|
|
||
| - name: push dev version | ||
| if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | ||
| run: | | ||
| docker push "ghcr.io/opencast/pyca:main" | ||
|
|
||
| - name: delete untagged container images | ||
| uses: snok/container-retention-policy@v3.0.1 | ||
| if: ${{ github.event_name == 'push' }} | ||
| with: | ||
| account: opencast | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| tag-selection: untagged | ||
| image-names: pyca | ||
| cut-off: 1y | ||
|
Comment on lines
+15
to
+80
Check warningCode 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}
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work since you are trying to use the
GITHUB_TOKENsecret in an environment which is controlled by the pull request author, isn't it? This would need to bepull_request_target.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GITHUB_TOKENis only used in steps with the conditiongithub.event_name == 'push'. The idea of includingpull_requestis to check if the container image still builds with the PR.