-
Notifications
You must be signed in to change notification settings - Fork 27
74 lines (60 loc) · 2.36 KB
/
cd-registrants-portal-api.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
name: cd-registrants-portal-api
on:
push:
branches:
- master
paths:
- "registrants/src/API/**"
- "shared/src/**"
- ".github/workflows/cd-registrants-portal-api.yml"
env:
IMAGE_NAME: registrants-portal-api
WORKING_DIRECTORY: ./registrants/src/API
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set image repository
id: set_image_repository
run: |
# Set image repository and change all uppercase to lowercase
DOCKER_REPOSITORY=$(echo ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }} | tr '[A-Z]' '[a-z]')
echo "::set-output name=docker-repository::$DOCKER_REPOSITORY"
- name: Pull image
env:
DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }}
run: docker pull $DOCKER_REPOSITORY:latest || true
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ${{ env.IMAGE_NAME }}=v
fetch_all_tags: true
- name: Build image
env:
DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }}
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
VERSION=$(echo "${{ steps.tag_version.outputs.new_tag }}" | awk -F=v '{print $NF}')
echo DOCKER_REPOSITORY=${{ env.DOCKER_REPOSITORY }}
echo VERSION=$VERSION
tar -czh . | docker build --load --tag ${{ env.DOCKER_REPOSITORY }}:latest --cache-from=${{ env.DOCKER_REPOSITORY }}:latest --build-arg VERSION=$VERSION -
docker tag ${{ env.DOCKER_REPOSITORY }}:latest ${{ env.DOCKER_REPOSITORY }}:$VERSION
- name: Push image
env:
DOCKER_REPOSITORY: ${{ steps.set_image_repository.outputs.docker-repository }}
run: |
docker push --all-tags ${{ env.DOCKER_REPOSITORY }}