-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (130 loc) · 4.37 KB
/
build.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 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: Auslan Signbank
on:
push:
branches:
- main
permissions:
contents: read
jobs:
# test:
# services:
# postgres:
# image: postgres:12
# ports: ["5432:5432"]
# env:
# POSTGRES_PASSWORD: postgres
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# name: Test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Set up Elixir
# uses: erlef/setup-beam@v1
# with:
# version-type: strict
# version-file: .tool-versions
# - name: Restore dependencies cache
# uses: actions/cache@v3
# with:
# path: deps
# key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
# restore-keys: ${{ runner.os }}-mix-
# - name: Install dependencies
# run: mix deps.get
# - name: Compiles without warnings
# run: mix compile
# env:
# MIX_ENV: test
# - name: Check formatting
# run: mix format --check-formatted
# env:
# MIX_ENV: test
# - name: Run tests
# run: mix test
# env:
# MIX_ENV: test
# DATABASE_HOST: localhost
# DATABASE_USER: postgres
# DATABASE_PASS: postgres
build:
name: Build release
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.output.outputs.artifact_name }}
artifact_filename: ${{ steps.output.outputs.artifact_filename }}
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Set release version
run: |
echo "VERSION=$(grep 'version:' mix.exs | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Release v${{ env.VERSION }}
run: |
mix compile
mix assets.deploy
mix release
env:
MIX_ENV: prod
- name: Set job output
id: output
run: |
echo "artifact_name=signbank-${{ env.VERSION }}" >> "$GITHUB_OUTPUT"
echo "artifact_filename=signbank-${{ env.VERSION }}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: signbank-${{ env.VERSION }}
path: _build/prod/signbank-${{ env.VERSION }}.tar.gz
deploy:
name: Deploy release
runs-on: ubuntu-latest
environment:
name: uat
url: https://uat.auslan.org.au
needs: build
steps:
- name: Download a Build Artifact
uses: actions/[email protected]
with:
name: ${{ needs.build.outputs.artifact_name }}
- name: Copy, untar and run release
# You may pin to the exact commit or the version.
# uses: cross-the-world/ssh-scp-ssh-pipelines@78e864b4890087a58248ff39320406971ca88b89
uses: cross-the-world/[email protected]
with:
host: ${{ vars.STAGING_REMOTE_HOST }}
port: 22
user: ${{ vars.STAGING_REMOTE_USER }}
key: ${{ secrets.STAGING_SSH_PRIVATE_KEY }}
first_ssh: mkdir -p ${{ vars.STAGING_REMOTE_TARGET }}/signbank
# scp from local to remote
scp: |
'${{ needs.build.outputs.artifact_filename }}' => "${{ vars.STAGING_REMOTE_TARGET }}/signbank"
last_ssh: |
tar -xzf signbank/${{ needs.build.outputs.artifact_filename }} --directory /opt/signbank
sudo mv /opt/signbank/*.service /etc/systemd/system --force
sudo systemctl daemon-reload
echo "Restarting existing application..."
sudo systemctl restart signbank
echo "Deleting release tarball..."
rm ${{ vars.STAGING_REMOTE_TARGET }}/signbank/${{ needs.build.outputs.artifact_filename }}