Update docker-compose.prod.yml #369
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
# This workflow occurs on all pushes, pull requests, and tagged releases | |
# It builds an image based on the current repo | |
# However, that image is only pushed to docker hub and loaded to the server when one of two conditions is met: | |
# 1. It is a tagged release | |
# 2. It is a commit containing the text 'Weekly data update' (case-insensitive) | |
# | |
# A tagged release of the repo leads to an image with the latest tag and a semantic-version tag | |
# A data update of the repo leads to an image with the latest tag and a tag that says data-update-<date> | |
name: Build and Deploy | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
R_KEEP_PKG_SOURCE: yes | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout GitHub repository | |
uses: actions/checkout@v4 | |
- name: Define Docker metadata | |
id: docker_metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: jamiecaldwell/uh-crw | |
tags: | | |
type=raw,value=latest | |
type=semver,pattern={{raw}} | |
type=raw,value=data-update-,suffix=${{ github.event.repository.updated_at }},enable=${{ contains(github.event.head_commit.message, 'Weekly data update') }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Pandoc | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: jamiecaldwell | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Checkout transcrypt | |
uses: actions/checkout@v4 | |
with: | |
repository: elasticdog/transcrypt | |
path: transcrypt | |
- name: Initialise transcrypt | |
run: ./transcrypt/transcrypt -p '${{ secrets.TRANSCRYPT_PASSWORD }}' --yes | |
- name: Build container image and push to dockerhub on a tagged release or a data update | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
push: ${{ github.event_name == 'release' || contains(github.event.head_commit.message, 'Weekly data update') }} | |
build-args: | | |
"event_sha=${{ github.sha }}" | |
- name: Deploy the image to the webserver on a tagged release or a data update | |
if: ${{ github.event_name == 'release' || contains(github.event.head_commit.message, 'Weekly data update') }} | |
run: ./infra/deploy.sh | |
shell: bash | |
env: | |
HOST: "66.228.47.179" | |
DOCKER_STACK_NAME: coral | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
DOCKER_ID: jamiecaldwell | |