-
Notifications
You must be signed in to change notification settings - Fork 40
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
Updates to container images #530
base: main
Are you sure you want to change the base?
Changes from all commits
b4d05b9
25007f6
5eb9361
1dc10eb
1efa6b7
271cfa1
ce47d38
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@v4 | ||
|
||
- name: set up Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
platforms: ${{ env.DOCKER_BUILDX_PLATFORM }} | ||
|
||
- uses: docker/login-action@v3 | ||
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
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 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/[email protected] | ||
if: ${{ github.event_name == 'push' }} | ||
with: | ||
account: opencast | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag-selection: untagged | ||
image-names: pyca | ||
cut-off: 1y |
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_TOKEN
secret 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_TOKEN
is only used in steps with the conditiongithub.event_name == 'push'
. The idea of includingpull_request
is to check if the container image still builds with the PR.