Skip to content

Merge pull request #160 from CodeForAfrica/dependabot/npm_and_yarn/sh… #50

Merge pull request #160 from CodeForAfrica/dependabot/npm_and_yarn/sh…

Merge pull request #160 from CodeForAfrica/dependabot/npm_and_yarn/sh… #50

Workflow file for this run

name: main
on:
push:
branches: [main]
env:
NEXT_PUBLIC_DASHBOARD_URL: "https://dashboard.covid19.outbreak.africa"
NEXT_PUBLIC_HOSTNAME: "outbreak.africa"
NEXT_PUBLIC_URL: "https://covid19.outbreak.africa"
DOKKU_REMOTE_BRANCH: "master"
DOKKU_REMOTE_URL: "ssh://[email protected]/outbreak"
GIT_PUSH_FLAGS: "--force"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Check if version is bumped
id: version-check
uses: EndBug/version-check@v1
with:
# Whether to search in every commit's diff.
# This is useful if you often do change the version without saying it
# in the commit message. If you always include the semver of the new
# version in your commit message when you bump versions then you can
# omit this.
diff-search: true
- name: Set up Docker Buildx
if: steps.version-check.outputs.changed == 'true'
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
if: steps.version-check.outputs.changed == 'true'
uses: actions/cache@v2
with:
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: /tmp/.buildx-cache
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: steps.version-check.outputs.changed == 'true'
uses: docker/login-action@v1
with:
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
username: ${{ secrets.DOCKER_HUB_USERNAME }}
- name: Build Docker image
if: steps.version-check.outputs.changed == 'true'
uses: docker/build-push-action@v2
with:
build-args: |
NEXT_PUBLIC_DASHBOARD_URL=${{ env.NEXT_PUBLIC_DASHBOARD_URL }}
NEXT_PUBLIC_HOSTNAME=${{ env.NEXT_PUBLIC_HOSTNAME }}
NEXT_PUBLIC_URL=${{ env.NEXT_PUBLIC_URL }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
push: true
tags: "codeforafrica/outbreak-africa-covid19:${{ steps.version-check.outputs.version }}"
- name: Move cache
if: steps.version-check.outputs.changed == 'true'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Push to Dokku
if: steps.version-check.outputs.changed == 'true'
uses: dokku/[email protected]
with:
branch: ${{ env.DOKKU_REMOTE_BRANCH }}
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
git_push_flags: ${{ env.GIT_PUSH_FLAGS }}
git_remote_url: ${{ env.DOKKU_REMOTE_URL }}