-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 2.34 KB
/
twoops-tracker-cd.yaml
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
# yamllint disable rule:line-length
name: TwoopsTracker | Continuous Deployment
"on":
push:
branches:
- main
paths:
- "twoops_tracker/py/VERSION"
env:
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]/twoopstracker"
GIT_PUSH_FLAGS: "--force"
IMAGE_NAME: "codeforafrica/twoopstracker"
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
build:
name: Build and Deploy
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set env
run: echo "VERSION=$(cat twoops_tracker/py/VERSION)" >> $GITHUB_ENV
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Initialize Pants
uses: pantsbuild/actions/init-pants@main
with:
# cache0 makes it easy to bust the cache if needed
gha-cache-key: cache0-py${{ matrix.python_version }}
named-caches-hash: ${{ hashFiles('lockfiles/*.json', '**/something-else.lock') }}
- name: Bootstrap Pants
run: |
pants --version
- name: Check BUILD files
run: ./pants tailor --check update-build-files --check
- name: Lint
run: |
pants lint --lint-skip-formatters twoops_tracker/::
- name: Build Docker image
run: |
VERSION=${{ env.VERSION }} ./pants package twoops_tracker/docker/::
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Push to DockerHub
run: |
docker push ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
- name: Push to Dokku
uses: dokku/[email protected]
with:
branch: ${{ env.DOKKU_REMOTE_BRANCH }}
git_push_flags: ${{ env.GIT_PUSH_FLAGS }}
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}