Merge pull request #607 from open5e/606-spell-schools-error-500 #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- name: Run Smoke Test | |
run: | | |
APP_URL=$(jq -r '.app.live_url' ./app.json) | |
python3 ./scripts/smoke_test.py --url $APP_URL |