-
Notifications
You must be signed in to change notification settings - Fork 14
109 lines (89 loc) · 3.83 KB
/
publish.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
name: Publish
on:
push:
branches: [master]
tags:
- v1.*
- v2.*
- v3.*
- v4.*
- v5.*
jobs:
test:
uses: ./.github/workflows/reusable-test.yml
secrets: inherit
publish-cloud:
runs-on: ubuntu-22.04
needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set RELEASE_VERSION env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build the Docker image for cloud
run: docker build . --file Dockerfile --target production --build-arg COMMIT_HASH=$GITHUB_SHA --build-arg PROPRIETARY_MODE=${{ secrets.PROPRIETARY_MODE }} --build-arg STRIPE_PUBLIC_API_KEY=${{ secrets.STRIPE_PUBLIC_API_KEY }} --build-arg TEXTERIFY_PAYMENT_SERVER=${{ secrets.TEXTERIFY_PAYMENT_SERVER }} --build-arg SENTRY_DSN_FRONTEND=${{ secrets.SENTRY_DSN_FRONTEND }} --tag chrztoph/texterify-cloud:$GITHUB_SHA
# Push to DigitalOcean registry
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200
- name: Tag DigitalOcean image
if: env.RELEASE_VERSION
run: docker tag chrztoph/texterify-cloud:$GITHUB_SHA registry.digitalocean.com/voidly/txty-cloud:$GITHUB_SHA
- name: Tag DigitalOcean image if env.RELEASE_VERSION is set
if: env.RELEASE_VERSION
run: docker tag chrztoph/texterify-cloud:$GITHUB_SHA registry.digitalocean.com/voidly/txty-cloud:${{ env.RELEASE_VERSION }}
- name: Push DigitalOcean GITHUB_SHA image to private registry
run: |
docker push registry.digitalocean.com/voidly/txty-cloud:$GITHUB_SHA
- name: Push DigitalOcean env.RELEASE_VERSION image to private registry
if: env.RELEASE_VERSION
run: |
docker push registry.digitalocean.com/voidly/txty-cloud:${{ env.RELEASE_VERSION }}
- name: Start garbage collection
run: yes | doctl registry garbage-collection start --force
# Slack error message
- name: Send notification to Slack if job fails
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
publish-on-premise:
runs-on: ubuntu-22.04
needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set RELEASE_VERSION env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image for on-premise
run: docker build . --file Dockerfile --target production --build-arg COMMIT_HASH=$GITHUB_SHA --tag chrztoph/texterify:$GITHUB_SHA
- name: Tag image also as latest
run: docker tag chrztoph/texterify:$GITHUB_SHA chrztoph/texterify:latest
- name: Push images
run: |
docker push chrztoph/texterify:$GITHUB_SHA
docker push chrztoph/texterify:latest
- name: Tag image if tag is set
if: env.RELEASE_VERSION
run: docker tag chrztoph/texterify:$GITHUB_SHA chrztoph/texterify:${{ env.RELEASE_VERSION }}
- name: Push images if tag is set
if: env.RELEASE_VERSION
run: |
docker push chrztoph/texterify:${{ env.RELEASE_VERSION }}
- name: Send notification to Slack if job fails
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()