-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (71 loc) · 2.68 KB
/
release.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
name: Services Release
on:
workflow_call:
inputs:
container_registry:
type: string
required: false
default: ghcr.io
environment:
type: string
required: false
secrets:
ghcr_token:
required: true
env:
ARTIFACT_RETENTION_DAYS: 7
jobs:
build-observation-service:
runs-on: ubuntu-latest
env:
APP_NAME: observation-service
DOCKER_FILE: images/observation-service/Dockerfile
outputs:
api-version: ${{ steps.build-image.outputs.api-version }}
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build Docker image
id: build-image
run: |
set -o pipefail
make BIN_NAME=$APP_NAME DOCKER_FILE=$DOCKER_FILE build-image | tee output.log
echo "::set-output name=api-version::$(sed -n 's%API version: \(.*\)%\1%p' output.log)"
- name: Save Docker image
run: |
docker image save \
--output observation-service.${{ steps.build-image.outputs.api-version }}.tar \
observation-service:${{ steps.build-image.outputs.api-version }}
- name: Publish Artifact
uses: actions/upload-artifact@v3
with:
name: observation-service.${{ steps.build-image.outputs.api-version }}.tar
path: observation-service.${{ steps.build-image.outputs.api-version }}.tar
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
publish-observation-service:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs:
- build-observation-service
steps:
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ inputs.container_registry }}
username: ${{ github.actor }}
password: ${{ secrets.ghcr_token }}
- name: Download Docker image tar
uses: actions/download-artifact@v2
with:
name: observation-service.${{ needs.build-observation-service.outputs.api-version }}.tar
- name: Publish Docker Image
env:
DOCKER_REPOSITORY: ${{ inputs.container_registry }}/${{ github.repository }}
run: |
docker image load --input observation-service.${{ needs.build-observation-service.outputs.api-version }}.tar
docker tag \
observation-service:${{ needs.build-observation-service.outputs.api-version }} \
${{ env.DOCKER_REPOSITORY }}/observation-service:${{ needs.build-observation-service.outputs.api-version }}
docker push ${{ env.DOCKER_REPOSITORY }}/observation-service:${{ needs.build-observation-service.outputs.api-version }}