Skip to content

Commit

Permalink
ci: update docker-publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
developStorm authored Jul 12, 2023
1 parent 2999801 commit 6e7d9c3
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- gcc/*

env:
IMAGE_NAME: caentainer-gcc
IMAGE_NAME: ${{ github.repository_owner }}/caentainer-gcc

jobs:
push:
Expand All @@ -15,44 +15,34 @@ jobs:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1

- name: Generate Image Tag
id: image-tag
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- uses: docker/setup-buildx-action@v2

echo "::set-output name=TAG::${IMAGE_ID}:${VERSION}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}

- name: Log into GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
pull: true
tags: ${{ steps.image-tag.outputs.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}-buildcache
cache-to: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}-buildcache,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
GITHUB_SHA=${{ github.sha }}
Expand Down

0 comments on commit 6e7d9c3

Please sign in to comment.