-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (78 loc) · 2.62 KB
/
ci-build.yaml
File metadata and controls
79 lines (78 loc) · 2.62 KB
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
on:
workflow_call:
inputs:
image:
required: true
type: string
ref:
required: true
type: string
name:
required: true
type: string
file:
required: false
type: string
default: "Dockerfile"
platforms:
required: false
type: string
default: "linux/x86_64"
secrets:
REGISTRY_SECRET:
required: true
SLACK_CHANNEL:
required: false
SLACK_TOKEN:
required: false
jobs:
build_image:
name: Image
runs-on: ubuntu-latest
steps:
- name: Extract tag as an ENV var
run: |
ref="${{ github.ref }}"
echo "TAG=${ref/refs\/tags\//}" >> $GITHUB_ENV
- name: Login to the Registry
uses: docker/login-action@v1
with:
registry: eu.gcr.io
username: _json_key
password: ${{ secrets.REGISTRY_SECRET }}
- name: Use EU Artifact Registry
# Should be removed after repos have been updated to use the eu prefix
id: use_eu_registry
run: |
if [[ ${{ inputs.image }} != eu.* ]]; then
echo "Adding EU prefix"
echo "::set-output name=image::eu.${{ inputs.image }}"
else
echo "EU prefix already present"
echo "::set-output name=image::${{ inputs.image }}"
fi
- name: Build and Push image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.use_eu_registry.outputs.image }}:${{ env.TAG }},${{ steps.use_eu_registry.outputs.image }}:latest
file: ${{ inputs.file }}
platforms: ${{ inputs.platforms }}
push: true
build-args: |
VERSION=${{ env.TAG }}
labels: |
source-url=https://github.com/${{ github.repository }}
- name: Notify Slack
if: ${{ inputs.SLACK_TOKEN && success() }}
uses: docker://automationcloud/rsslack:latest
with:
channel: ${{ secrets.slack_channel }}
slack_token: ${{ secrets.SLACK_TOKEN }}
message: ":package: *${{ inputs.name }}* has been built and pushed to `${{ steps.use_eu_registry.outputs.image }}:${{ env.TAG }}`"
- name: Notify Slack on Failure
if: ${{ inputs.SLACK_TOKEN && failure() }}
uses: docker://automationcloud/rsslack:latest
with:
channel: ${{ secrets.SLACK_CHANNEL }}
slack_token: ${{ secrets.SLACK_TOKEN }}
message: ":suspicious: *${{ inputs.name }}* build failed - Run <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>"