-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (95 loc) · 3.4 KB
/
cd.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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: 🌳 Continuous Deployment
run-name: 🚀 Deploying the app to production
on:
push:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
foundation:
name: 🌱 Foundation setup
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
# https://github.com/actions/checkout/tree/11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
# https://github.com/rymndhng/release-on-push-action/tree/aebba2bbce07a9474bf95e8710e5ee8a9e922fe2
- name: 🏷️ Create tag and release notes
uses: rymndhng/release-on-push-action@aebba2bbce07a9474bf95e8710e5ee8a9e922fe2
id: release
with:
bump_version_scheme: patch
use_github_release_notes: true
env:
GITHUB_TOKEN: ${{ github.token }}
- name: 📦 Set the version
id: version
run: echo "version=$(echo "${{ steps.release.outputs.tag_name }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
build:
name: 🏗️ Build
needs: foundation
uses: ./.github/workflows/build.yml
strategy:
fail-fast: false
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#example-adding-configurations
matrix:
include:
- image: urbantree
context: ./app
- image: api
context: ./api
permissions:
contents: read
packages: write
attestations: write
id-token: write
with:
context: ${{ matrix.context }}
environment: ${{ needs.foundation.outputs.version && 'production' }}
image: ${{ matrix.image }}
version: ${{ needs.foundation.outputs.version }}
secrets: inherit
database:
name: 🏗️ Build database
needs: foundation
uses: ./.github/workflows/database.yml
permissions:
contents: read
packages: write
attestations: write
id-token: write
with:
version: ${{ needs.foundation.outputs.version }}
secrets: inherit
release:
name: 🚀 Release
needs: [build, database]
if: ${{ needs.build.outputs.version && needs.database.outputs.version }}
runs-on: ubuntu-latest
environment: Production
steps:
# https://github.com/appleboy/ssh-action/tree/7eaf76671a0d7eec5d98ee897acda4f968735a17
- name: 🚚 SSH into production server
uses: appleboy/ssh-action@7eaf76671a0d7eec5d98ee897acda4f968735a17
with:
host: ${{ secrets.SSH_MANAGER_HOST }}
username: ${{ secrets.SSH_MANAGER_USER }}
password: ${{ secrets.SSH_MANAGER_PASS }}
port: ${{ secrets.SSH_MANAGER_PORT }}
script: ${{ secrets.SSH_MANAGER_SCRIPT }}
# https://github.com/jtalk/url-health-check-action/tree/b716ccb6645355dd9fcce8002ce460e5474f7f00
- name: 🕵️ Check the deployment
uses: jtalk/url-health-check-action@b716ccb6645355dd9fcce8002ce460e5474f7f00
with:
url: ${{ vars.API_URL }}|${{ vars.APP_URL }}
max-attempts: 5
retry-delay: 8s
retry-all: true