-
Notifications
You must be signed in to change notification settings - Fork 5
89 lines (75 loc) · 2.37 KB
/
deploy.yml
File metadata and controls
89 lines (75 loc) · 2.37 KB
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
name: Deploy
on:
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
packages: write
env:
SQLFLUFF_DIALECT: postgres
DOCKER_IMAGE: flyway/flyway
SCHEMAS: public
jobs:
deploy:
runs-on: ubuntu-22.04-arm
steps:
- name: Checkout
uses: actions/checkout@v2
# run tests
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Tests
run: dotnet test -c Release --logger "trx;LogFileName=test-results.trx"
# upload test results
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: "**/*.trx"
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Setup WireGuard VPN
run: |
sudo apt-get update && sudo apt-get install -y wireguard resolvconf
echo "${{ secrets.WIREGUARD_CONFIG }}" | sudo tee /etc/wireguard/wg0.conf > /dev/null
sudo chmod 600 /etc/wireguard/wg0.conf
sudo wg-quick up wg0
# Verify VPN is up
sudo wg show
# if tests are ok, deploy to production
- name: Apply migrations to production DB
run: >-
docker run --rm
--network host
--volume ${{ github.workspace }}/src/migrations:/flyway/sql:ro
--volume ${{ github.workspace }}/reports:/flyway/reports
"${{ env.DOCKER_IMAGE }}"
-url="${{ secrets.DB_PROD_URL }}"
-user="${{ secrets.DB_PROD_USERNAME }}"
-password="${{ secrets.DB_PROD_PASSWORD }}"
migrate -schemas="${{ env.SCHEMAS }}"
- name: Disconnect VPN
if: always()
run: sudo wg-quick down wg0 || true
- name: Upload Flyway report
uses: actions/upload-artifact@v4
with:
name: Database Report
path: reports/
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push to GHCR
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/fsharplang-ru/vahter-bot:${{ github.sha }}, ghcr.io/fsharplang-ru/vahter-bot:latest
file: ./Dockerfile
platforms: linux/arm64