generated from Saluki/nestjs-template
-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (70 loc) · 2.33 KB
/
payment-api.build.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
name: Payment api build and test
on:
push:
branches:
- master
paths:
- payment-api/**
- .github/workflows/payment-api.build.yml
pull_request:
branches:
- master
paths:
- payment-api/**
- .github/workflows/payment-api.build.yml
env:
image: ms-course-payment-api
jobs:
docker-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./payment-api
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Set up QEMU
uses: docker/[email protected]
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: nyaa8/package-version@v1
with:
path: "payment-api/package.json" # Optional
- name: Get latest tag
id: latest_tag
uses: jacobtomlinson/[email protected]
with:
org: ${{secrets.DOCKER_HUB_USERNAME}} # Docker Hub user or organisation name
repo: ${{env.image}} # Docker Hub repository name
# Optionally check the tag we got back
- name: Check outputs
run: |
echo "Latest ${{env.image}} Tag - ${{ steps.latest_tag.outputs.tag }}"
- name: Build and push
id: docker_build
uses: docker/[email protected]
with:
context: ./payment-api
file: ./payment-api/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: ${{ steps.latest_tag.outputs.tag != env.PACKAGE_VERSION }}
tags:
${{ secrets.DOCKER_HUB_USERNAME }}/${{env.image}}:${{ env.PACKAGE_VERSION }},
${{ secrets.DOCKER_HUB_USERNAME }}/${{env.image}}:latest
platforms: linux/amd64, linux/arm64/v8
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}