-
Notifications
You must be signed in to change notification settings - Fork 24
49 lines (41 loc) · 1.4 KB
/
publish-docker.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
# Workflow is triggered after a new Optimizt version is successfully published to NPM
name: Build and publish Docker image
on:
workflow_run:
workflows: [Publish Package to npmjs]
types: [completed]
branches: [master]
defaults:
run:
shell: bash
jobs:
docker:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Check-out repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Define variables
run: |
echo "OPTIMIZT_VERSION=$(grep -m1 version ./package.json | sed 's/[", ]//g' | cut -d ":" -f 2)" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: funbox/optimizt:latest,funbox/optimizt:${{ env.OPTIMIZT_VERSION }}
build-args: |
OPTIMIZT_VERSION=${{ env.OPTIMIZT_VERSION }}
BUILD_DATE=${{ env.BUILD_DATE }}
fail:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo "Publish workflow failed"