-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (87 loc) · 2.83 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Publish
on:
workflow_call:
inputs:
prefix:
description: Optional image prefix for branch build
required: false
type: string
version:
description: Optional custom image version tag
required: false
type: string
secrets:
SLACK_WEBHOOK_URL:
SLACK_MENTION_GROUP_ID:
outputs:
version:
description: Docker image version
value: ${{ jobs.docker.outputs.version }}
jobs:
docker:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Outputs the name of the repository (owner/repo)
- name: Build Image Name
id: image
run: |
# The name of the owner and of the repository: owner/repository
IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ steps.image.outputs.image_name }}
tags: |
type=ref,event=branch,prefix=${{ inputs.prefix }}
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=raw,value=${{ inputs.version }},enable=${{ inputs.version != null }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Image digest
run: |
echo $"\
Digest: ${{ steps.docker_build.outputs.digest }}
Tags: ${{ steps.meta.outputs.tags }}"
- name: Notify Slack
if: ${{ failure() }}
env:
JOB_STATUS: ${{ job.status }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_MENTION_GROUP_ID }}
JOB_TITLE: "Build of Saleor Core ${{ steps.meta.outputs.version }}"
run: |
python3 ./.github/workflows/notify/notify-slack.py