Deploy Production #5
Workflow file for this run
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: Deploy Production | |
env: | |
REPO_NAME: ${{ github.event.repository.name }} | |
REPO_OWNER: ${{ github.repository_owner }} | |
on: | |
workflow_dispatch: | |
release: | |
types: [created] | |
jobs: | |
build_and_tag: | |
runs-on: ubuntu-latest | |
environment: Production | |
services: | |
docker: | |
image: docker:19.03.5-dind | |
options: --privileged | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: live | |
- name: Build Docker image | |
run: | | |
export DATABASE_URL=${{ secrets.DATABASE_URL }} | |
export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} | |
export DISCORD_CLIENT_ID=${{ secrets.DISCORD_CLIENT_ID }} | |
export DISCORD_CLIENT_SECRET=${{ secrets.DISCORD_CLIENT_SECRET }} | |
export UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }} | |
export UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }} | |
docker build -t in-house-queue-site . | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Log in to DigitalOcean Container Registry with short-lived credentials | |
run: doctl registry login --expiry-seconds 600 | |
- name: Get the latest release tag | |
id: latest_release | |
run: | | |
tag=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" "https://api.github.com/repos/${{ env.REPO_OWNER }}/${{ env.REPO_NAME }}/releases/latest" | jq -r ".tag_name") | |
echo "TAG=$tag" >> $GITHUB_ENV | |
- name: Tag and push Docker image | |
run: | | |
export DO_REPOSITORY=${{ secrets.DO_REPO }} | |
TAG=${{ env.TAG }} | |
docker tag in-house-queue-site:latest $DO_REPOSITORY:$TAG | |
docker push $DO_REPOSITORY:$TAG |