Skip to content
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

Fix build image on tags #1858

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-image-on-tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
id-token: write
uses: ./.github/workflows/build-image.yaml
with:
buildType: build_push_ckan
buildType: build_push_ckan_with_gittag
gitRef: ${{ github.ref_name }}
40 changes: 27 additions & 13 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
options:
- build_only
- build_push_ckan
- build_push_ckan_with_gittag
- build_push_base
- build_push_pycsw
- build_push_solr
Expand Down Expand Up @@ -98,6 +99,12 @@ jobs:
run: |
buildType="${{ env.BUILD_TYPE }}"

if [ "$buildType" = "build_push_ckan_with_gittag" ]; then
echo "GH_TAG=${{ inputs.gitRef || github.ref }}" >> $GITHUB_ENV
else
echo "GH_TAG=${{ github.sha }}" >> $GITHUB_ENV
fi

case $buildType in
"build_only" | "build_push_pycsw")
echo "BUILD_TAGS=${{ matrix.app.version }}" >> $GITHUB_ENV
Expand All @@ -120,6 +127,11 @@ jobs:
echo "APP_TAG_SUFFIX=-core" >> $GITHUB_ENV
;;

"build_push_ckan_with_gittag")
echo "BUILD_TAGS=${{ inputs.gitRef || github.ref }}" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}" >> $GITHUB_ENV
;;

*)
echo "BUILD_TAGS=${{ matrix.app.version }}-${{ matrix.app.patch }}" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}-${{ matrix.app.patch }}" >> $GITHUB_ENV
Expand All @@ -135,7 +147,7 @@ jobs:
images: |
${{ env.REGISTRY_BASE }}/${{ matrix.app.name }}
tags: |
type=raw,value=${{ github.sha }}
type=raw,value=${{ env.GH_TAG }}
type=raw,value=${{ env.BUILD_TAGS }}${{ env.APP_TAG_SUFFIX }}
type=raw,value=${{ env.BUILD_TAGS }}-${{ matrix.app.patch }}${{ env.APP_TAG_SUFFIX }},enable=${{ matrix.app.patch != '' && env.ADD_PATCH_TAG == 'true' }}
type=sha,prefix${{ env.BUILD_TAGS }}${{ env.APP_TAG_SUFFIX }}-,format=short
Expand Down Expand Up @@ -250,26 +262,23 @@ jobs:
- name: Setup Docker BuildX
uses: docker/setup-buildx-action@v3

- name: Show GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Get Git Head
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
id: local-head

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Image Tags
id: determine-image-tags
run: |
buildType="${{ env.BUILD_TYPE }}"

if [ "$buildType" = "build_push_ckan_with_gittag" ]; then
echo "GH_TAG=${{ inputs.gitRef || github.ref }}" >> $GITHUB_ENV
else
echo "GH_TAG=${{ github.sha }}" >> $GITHUB_ENV
fi

case $buildType in
"build_only" | "build_push_pycsw")
Expand All @@ -291,6 +300,11 @@ jobs:
echo "APP_TAG_SUFFIX=-core" >> $GITHUB_ENV
;;

"build_push_ckan_with_gittag")
echo "BUILD_TAGS=${{ inputs.gitRef || github.ref }}" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}" >> $GITHUB_ENV
;;

*)
echo "BUILD_TAGS=${{ matrix.app.version }}-${{ matrix.app.patch }}" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}-${{ matrix.app.patch }}" >> $GITHUB_ENV
Expand All @@ -313,7 +327,7 @@ jobs:
images: |
${{ env.REGISTRY_BASE }}/${{ matrix.app.name }}
tags: |
type=raw,value=${{ github.sha }}
type=raw,value=${{ env.GH_TAG }}
type=raw,value=${{ env.BUILD_TAGS }}${{ env.APP_TAG_SUFFIX }}
type=raw,value=${{ env.BUILD_TAGS }}-${{ matrix.app.patch }}${{ env.APP_TAG_SUFFIX }},enable=${{ matrix.app.patch != '' && env.ADD_PATCH_TAG == 'true' }}
type=sha,prefix${{ env.BUILD_TAGS }}${{ env.APP_TAG_SUFFIX }}-,format=short
Expand Down Expand Up @@ -382,4 +396,4 @@ jobs:
env:
IMAGEREF: '${{ env.REGISTRY_BASE }}/${{ matrix.app.name }}:${{ steps.base-metadata.outputs.version }}'
run: |
docker buildx imagetools inspect "$IMAGEREF"
docker buildx imagetools inspect "$IMAGEREF"
2 changes: 2 additions & 0 deletions build-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ build_types:
- *app_solr
build_push_ckan:
- *app_ckan
build_push_ckan_with_gittag:
- *app_ckan
build_push_base:
- *app_ckan
build_push_pycsw:
Expand Down
Loading