forked from saleor/saleor-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.38 KB
/
publish-containers.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Publish container image
on:
release:
types: [published]
jobs:
docker:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
# Outputs the name of the repository (owner/repo)
- name: Get image name
id: image
run: |
IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
echo "image_name=ghcr.io/${IMAGE_NAME}" >> $GITHUB_OUTPUT
# Tags stable versions as :latest
# Pre-releases, alphas, etc. as :snapshot
- name: Output image tags from git tag events
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GH_TOKEN: ${{ github.token }}
run: |
LATEST_VERSION=$(gh api repos/saleor/saleor-dashboard/releases/latest | jq -r .tag_name)
CURRENT_TAG=${GITHUB_REF#refs/tags/}
if [ "$LATEST_VERSION" = "$CURRENT_TAG" ]; then
TAGS=${{ steps.image.outputs.image_name }}:${CURRENT_TAG},${{ steps.image.outputs.image_name }}:latest
else
TAGS=${{ steps.image.outputs.image_name }}:${CURRENT_TAG}
fi
echo "
DASHBOARD_VERSION=${CURRENT_TAG}
CONTAINER_TAGS=${TAGS}
" >> "${GITHUB_ENV}"
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: arm64
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.CONTAINER_TAGS }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
COMMIT_ID=${{ github.sha }}
PROJECT_VERSION=$DASHBOARD_VERSION
- name: Output image digest
run: |
echo $"\
Digest: ${{ steps.docker_build.outputs.digest }}
Tags: ${{ env.CONTAINER_TAGS }}"