Skip to content

Commit 9f5a8c4

Browse files
committed
build(docker): standardise docker build pipeline
1 parent df2f5e2 commit 9f5a8c4

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/docker.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
name: Docker Build and Push
1+
name: Docker
22

33
on:
44
push:
55
branches: [ master, release/* ]
6+
tags: [ '**' ]
7+
8+
env:
9+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
610

711
jobs:
812
build:
13+
name: Build & Push
914
runs-on: ubuntu-latest
1015
env:
11-
REPOSITORY_URL: docker.pkg.github.com
12-
IMAGE_NAME: ${{ github.repository }}/alerta-cli
13-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
16+
REPOSITORY_URL: ghcr.io
17+
IMAGE_NAME: ${{ github.repository_owner }}/alerta-cli
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v2
@@ -22,16 +26,18 @@ jobs:
2226
run: >-
2327
docker build
2428
-t $IMAGE_NAME
29+
-t $REPOSITORY_URL/$IMAGE_NAME:$(cat VERSION)
2530
-t $REPOSITORY_URL/$IMAGE_NAME:${{ steps.vars.outputs.SHORT_COMMIT_ID }}
2631
-t $REPOSITORY_URL/$IMAGE_NAME:latest .
2732
- name: Docker Login
28-
env:
29-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
30-
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
31-
run: docker login $REPOSITORY_URL --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"
33+
uses: docker/login-action@v1
34+
with:
35+
registry: ${{ env.REPOSITORY_URL }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
3238
- name: Publish Image
3339
id: docker-push
34-
run: docker push $REPOSITORY_URL/$IMAGE_NAME
40+
run: docker push --all-tags $REPOSITORY_URL/$IMAGE_NAME
3541

3642
- uses: act10ns/slack@v1
3743
with:

0 commit comments

Comments
 (0)