Unverified Commit b9864244 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

CI/CD - Fix image merge in GitHub Action. (#749)

Fix image merge for release event in GitHub Action.
parent 60189dd6
...@@ -220,8 +220,9 @@ jobs: ...@@ -220,8 +220,9 @@ jobs:
fi fi
if [[ "${{ github.event_name }}" == "release" ]]; then if [[ "${{ github.event_name }}" == "release" ]]; then
TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS}) TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS})
GHCR_TAG=$(cut -d, -f1 <<< ${TAGS} | sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g") GHCR_TAGS=$(sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g" <<< ${TAGS})
TAGS="${TAGS},${GHCR_TAG}" SOURCES=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${SOURCES})
GHCR_SOURCES=$(sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g" <<< ${SOURCES})
fi fi
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS}) TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS})
...@@ -230,6 +231,8 @@ jobs: ...@@ -230,6 +231,8 @@ jobs:
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
echo "sources=${SOURCES}" >> "$GITHUB_OUTPUT" echo "sources=${SOURCES}" >> "$GITHUB_OUTPUT"
echo "ghcr_tags=${GHCR_TAGS}" >> "$GITHUB_OUTPUT"
echo "ghcr_sources=${GHCR_SOURCES}" >> "$GITHUB_OUTPUT"
- name: Echo image tags - name: Echo image tags
run: echo ${{ steps.metadata.outputs.tags }} run: echo ${{ steps.metadata.outputs.tags }}
- name: Echo image sourcs - name: Echo image sourcs
...@@ -251,7 +254,7 @@ jobs: ...@@ -251,7 +254,7 @@ jobs:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Merge and push - name: Merge and push to Docker Hub
if: ${{ github.event_name != 'pull_request' }} if: ${{ github.event_name != 'pull_request' }}
run: | run: |
docker buildx imagetools create \ docker buildx imagetools create \
...@@ -260,6 +263,15 @@ jobs: ...@@ -260,6 +263,15 @@ jobs:
--annotation "index:org.opencontainers.image.revision=${{ github.sha }}" \ --annotation "index:org.opencontainers.image.revision=${{ github.sha }}" \
--tag ${{ steps.metadata.outputs.tags }} \ --tag ${{ steps.metadata.outputs.tags }} \
${{ steps.metadata.outputs.sources }} ${{ steps.metadata.outputs.sources }}
- name: Merge and push to GitHub Container Registry
if: ${{ github.event_name == 'release' }}
run: |
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.source=${{ github.event.repository.html_url }}" \
--annotation "index:org.opencontainers.image.created=${{ github.event.repository.pushed_at }}" \
--annotation "index:org.opencontainers.image.revision=${{ github.sha }}" \
--tag ${{ steps.metadata.outputs.ghcr_tags }} \
${{ steps.metadata.outputs.ghcr_sources }}
- name: Inspect image - name: Inspect image
if: ${{ github.event_name != 'pull_request' }} if: ${{ github.event_name != 'pull_request' }}
run: | run: |
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment