-
Notifications
You must be signed in to change notification settings - Fork 21
115 lines (101 loc) · 3.95 KB
/
docker_image_public_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# This workflow publishes a new docker image to 'https://hub.docker.com/r/stellar/stellar-disbursement-platform-backend'
# when a new release is created or when we merge something to the develop branch.
name: Docker Image Public Release
on:
release:
types:
- published
push:
branches:
- develop
jobs:
tests:
uses: ./.github/workflows/ci.yml # execute the callable ci.yml
secrets: inherit # pass all secrets
anchor_platform_integration_check:
uses: ./.github/workflows/anchor_platform_integration_check.yml # execute the callable anchor_platform_integration_check.yml
needs:
- tests
secrets: inherit # pass all secrets
e2e_integration_test:
uses: ./.github/workflows/e2e_integration_test.yml # execute the callable e2e_integration_test.yml
needs:
- tests
secrets: inherit # pass all secrets
build_and_push_docker_image_on_release:
if: github.event_name == 'release'
name: Push to DockerHub (release prd) # stellar/stellar-disbursement-platform-backend:{VERSION}
runs-on: ubuntu-latest
needs:
- tests
- anchor_platform_integration_check
- e2e_integration_test
steps:
- name: Check if tag is not empty
run: |
if [[ -z "${{ github.event.release.tag_name }}" ]]; then
echo "Release tag name cannot be empty."
exit 1
fi
- name: Determine Docker Tags
id: docker_tags
run: |
if [ "${{ github.event.release.prerelease }}" = "false" ]; then
echo "TAGS=stellar/stellar-disbursement-platform-backend:${{ github.event.release.tag_name }},stellar/stellar-disbursement-platform-backend:latest" >> $GITHUB_OUTPUT
else
echo "TAGS=stellar/stellar-disbursement-platform-backend:${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to DockerHub (release prd)
uses: docker/build-push-action@v6.9.0
with:
push: true
build-args: |
GIT_COMMIT=${{ github.event.release.tag_name }}
tags: ${{ steps.docker_tags.outputs.TAGS }}
file: Dockerfile
build_and_push_docker_image_on_dev_push:
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
name: Push to DockerHub (release develop branch) # stellar/stellar-disbursement-platform-backend:edge-{DATE}-{SHA}
runs-on: ubuntu-latest
needs:
- tests
- anchor_platform_integration_check
- e2e_integration_test
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get current date
id: get_date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Get SHA
shell: bash
id: get_sha
run: echo "SHA=$(git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT
- name: Build and push to DockerHub (develop branch)
uses: docker/build-push-action@v6.9.0
with:
push: true
build-args: |
GIT_COMMIT=${{ steps.get_sha.outputs.SHA }}
tags: stellar/stellar-disbursement-platform-backend:edge,stellar/stellar-disbursement-platform-backend:edge-${{ steps.get_date.outputs.DATE }}-${{ steps.get_sha.outputs.SHA }}
file: Dockerfile
complete:
if: always()
needs:
- build_and_push_docker_image_on_release
- build_and_push_docker_image_on_dev_push
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
# TODO: figure out which job failed and print the logs