-
Notifications
You must be signed in to change notification settings - Fork 67
49 lines (45 loc) · 1.63 KB
/
build-and-deploy.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
name: Deploy to Staging
concurrency: deploy_to_staging
on:
push:
branches: [ "main" ]
env:
STAGING_ID: cc67ac7f-d41b-4a9c-a2ce-37f322690cb8
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update the project version
run: |
OLD_VERSION=$(python -c 'import version; print(version.version)')
pip install python-semantic-release==9.4.1 && python -m semantic_release version --no-changelog
NEW_VERSION=$(python -c 'import version; print(version.version)')
if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
echo "No new version generated, can't deploy"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Build the Docker image
run: |
export VERSION=$(python -c 'import version; print(version.version)')
docker build . --file Dockerfile --tag registry.digitalocean.com/openunited/core:$VERSION
- name: Login to registry
run: doctl registry login --expiry-seconds 600
- name: Push to DigitalOcean
run: docker push -a registry.digitalocean.com/openunited/core
- name: Fetch current spec file
run: doctl apps spec get $STAGING_ID > spec.yaml
- name: Update image tag
run: |
export VERSION=$(python -c 'import version; print(version.version)')
sed -i "s/\(.*tag: \).*/\1$VERSION/" spec.yaml
- name: Update the environment
run: doctl apps update $STAGING_ID --spec spec.yaml