-
Notifications
You must be signed in to change notification settings - Fork 2
62 lines (57 loc) · 1.99 KB
/
image-builder.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
# Build a docker image on push to main
# Also tag the image if commit is tagged
name: "Image Builder"
on:
push:
branches:
- "main"
- "azalea"
paths:
- "**.js"
- "**.json"
- "Dockerfile"
jobs:
build-image:
runs-on: ubuntu-latest
env:
IMAGE_NAME: "cennznet/bridge-relayer"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build 🛠 & Publish 🐳
env:
DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# build and tag an image with commit hash and 'latest'
# if the commit is tagged, tag the image also e.g. 1.0.0
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "commit hash: $COMMIT_HASH"
COMMIT_TAG=$((git describe --exact-match --tags HEAD) || true)
echo "commit tag(?): $COMMIT_TAG"
docker build -t "$IMAGE_NAME":"$COMMIT_HASH" -t "$IMAGE_NAME":latest -f ./Dockerfile .
docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
docker push $IMAGE_NAME:$COMMIT_HASH
docker push $IMAGE_NAME:latest
if [ -n "$COMMIT_TAG" ]; then
docker tag $IMAGE_NAME:$COMMIT_HASH $IMAGE_NAME:$COMMIT_TAG
docker push $IMAGE_NAME:$COMMIT_TAG
fi
- name: notify success
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: "status bot"
SLACK_ICON_EMOJI: ":whale:"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: "bridge/relayer image published :white_check_mark:"
- name: notify failure
if: ${{ failure() && !cancelled() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: "status bot"
SLACK_ICON_EMOJI: ":whale:"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: "bridge/realyer image build failed :x:"
SLACK_COLOR: "#ff0000"