-
Notifications
You must be signed in to change notification settings - Fork 100
53 lines (50 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
50
51
52
53
name: "Build and deploy"
on:
push:
branches:
- staging
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Docker image tag
run: |
echo "GITHUB_REF = $GITHUB_REF" > version.py
echo "GITHUB_SHA = $GITHUB_SHA" >> version.py
if [[ $GITHUB_REF == refs/heads/main ]]; then
echo "DOCKER_IMAGE_TAG=latest" >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/heads/staging ]]; then
echo "DOCKER_IMAGE_TAG=staging" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: eepmoody/open5e-api:${{ env.DOCKER_IMAGE_TAG }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install jq
- name: Set Digital Ocean app id
run: |
if [[ $GITHUB_REF == refs/heads/main ]]; then
echo "DIGITALOCEAN_APP_ID=${{ secrets.MAIN_APP_ID }}" >> $GITHUB_ENV
elif [[ $GITHUB_REF == refs/heads/staging ]]; then
echo "DIGITALOCEAN_APP_ID=${{ secrets.STAGING_APP_ID }}" >> $GITHUB_ENV
fi
- name: Deploy to Digital Ocean
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
run: ./scripts/do_app_deploy.sh