-
Notifications
You must be signed in to change notification settings - Fork 2
88 lines (76 loc) · 2.82 KB
/
release.yaml
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
86
87
88
name: release
on:
push:
tags:
- 'v*'
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: cic-ussd
DOCKER_DESCRIPTION: A ussd client implementation that interfaces with the community inclusion currencies custodial system.
IMAGE_TAG: ghcr.io/grassrootseconomics/cic-ussd/cic-ussd
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Authenticate with Docker registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set outputs
run: |
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV \
&& echo "RELEASE_SHORT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker buildx build \
--progress plain \
--tag ${{ env.IMAGE_TAG }}:${{ env.RELEASE_TAG }} \
--tag ${{ env.IMAGE_TAG }}:latest \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache \
--push .
- name: Tag Docker image with version
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: ${{ env.IMAGE_TAG }}:${{ env.RELEASE_TAG }}
labels: |
org.opencontainers.image.title=${{ env.DOCKER_IMAGE_NAME }}
org.opencontainers.image.description=${{ env.DOCKER_DESCRIPTION }}
org.opencontainers.image.version=${{ env.RELEASE_TAG }}
- name: Push Docker image with version tag
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.IMAGE_TAG }}:${{ env.RELEASE_TAG }}
labels: |
org.opencontainers.image.title=${{ env.DOCKER_IMAGE_NAME }}
org.opencontainers.image.description=${{ env.DOCKER_DESCRIPTION }}
org.opencontainers.image.version=${{ env.RELEASE_TAG }}
- name: Push Docker image with latest tag
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.IMAGE_TAG }}:latest
labels: |
org.opencontainers.image.title=${{ env.DOCKER_IMAGE_NAME }}
org.opencontainers.image.description=${{ env.DOCKER_DESCRIPTION }}
org.opencontainers.image.version=latest