Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
kentsanggds committed Oct 22, 2024
1 parent a69e59d commit 7a1d18e
Showing 1 changed file with 24 additions and 33 deletions.
57 changes: 24 additions & 33 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,8 @@ jobs:
run: |
buildType="${{ env.BUILD_TYPE }}"
echo "==== check directory"
ls -la
if [ "$buildType" = "build_push_ckan_with_gittag" ]; then
export TAG=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`
echo "===== tag = $TAG"
TAG=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`
echo "GH_REF=$TAG" >> $GITHUB_ENV
else
echo "GH_REF=${{ github.sha }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -133,7 +129,6 @@ jobs:
;;
"build_push_ckan_with_gittag")
echo "==== gittag $TAG"
echo "BUILD_TAGS=$TAG" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}" >> $GITHUB_ENV
;;
Expand Down Expand Up @@ -227,7 +222,6 @@ jobs:
env:
DIGEST: "${{ steps.build-app-image.outputs.digest }}"
run: |
echo "----- ${{ env.BUILD_TAGS }}"
mkdir -p /tmp/digests/app
touch "/tmp/digests/app/${DIGEST#sha256:}"
Expand All @@ -237,7 +231,6 @@ jobs:
env:
DIGEST: "${{ steps.build-base-image.outputs.digest }}"
run: |
echo "----- ${{ env.BUILD_TAGS }}"
mkdir -p /tmp/digests/base
touch "/tmp/digests/base/${DIGEST#sha256:}"
Expand Down Expand Up @@ -276,17 +269,17 @@ 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: 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"
echo "GH_REF=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`" >> $GITHUB_ENV
echo $GH_REF
id: local-head
# - name: Get Git Head
# run: |
# echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# echo "GH_REF=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`" >> $GITHUB_ENV
# echo $GH_REF
# id: local-head

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -295,29 +288,28 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Export Image Digests
if: ${{ env.BUILD_TYPE != 'build_only' }}
id: export-digests
env:
DIGEST: "${{ steps.build-app-image.outputs.digest }}"
run: |
mkdir -p /tmp/digests/app
touch "/tmp/digests/app/${DIGEST#sha256:}"
# - name: Export Image Digests
# if: ${{ env.BUILD_TYPE != 'build_only' }}
# id: export-digests
# env:
# DIGEST: "${{ steps.build-app-image.outputs.digest }}"
# run: |
# mkdir -p /tmp/digests/app
# touch "/tmp/digests/app/${DIGEST#sha256:}"

- name: Determine Image Tags
id: determine-image-tags
run: |
buildType="${{ env.BUILD_TYPE }}"
if [ "$buildType" = "build_push_ckan_with_gittag" ]; then
echo "===== list directory"
sudo apt-get install -y git
mkdir -p /tmp/digests/app
git config --global --add safe.directory "$GITHUB_WORKSPACE"
echo "GH_REF=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`" >> $GITHUB_ENV
# git config --global --add safe.directory "$GITHUB_WORKSPACE"
TAG=`echo $(git fetch -t -q && git tag | sort --version-sort | tail -n1)`
echo "GH_REF=$TAG" >> $GITHUB_ENV
else
echo "GH_REF=${{ github.sha }}" >> $GITHUB_ENV
fi
Expand All @@ -343,7 +335,7 @@ jobs:
;;
"build_push_ckan_with_gittag")
echo "BUILD_TAGS=$GH_REF" >> $GITHUB_ENV
echo "BUILD_TAGS=$TAG" >> $GITHUB_ENV
echo "DOCKERFILE=${{ matrix.app.version }}" >> $GITHUB_ENV
;;
Expand Down Expand Up @@ -389,7 +381,6 @@ jobs:
working-directory: /tmp/digests/app
run: |
tag_args=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
echo "======== tag args = $tag_args"
ls /tmp/digests -la
printf -v sources "${IMAGEREF_PREFIX}@sha256:%s " *
# shellcheck disable=SC2086 # Intentional word-splitting on $tag_args and $sources.
Expand Down Expand Up @@ -440,4 +431,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"

0 comments on commit 7a1d18e

Please sign in to comment.