Limit scope of simplemappr exports #7239
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: deliver | |
on: | |
push: | |
branches: | |
- development | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-*' | |
pull_request: | |
branches: | |
- development | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
deliver: | |
if: | | |
!( | |
contains(github.event.head_commit.message, '[ci skip]') || | |
contains(github.event.head_commit.message, '[ci-skip]') || | |
contains(github.event.head_commit.message, '[skip ci]') || | |
contains(github.event.head_commit.message, '[skip-ci]') | |
) | |
env: | |
REF_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
CACHE_PATH: ".github/.docker-cache" | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Get startup date | |
id: datetime | |
run: echo "year_week=$(date -u +'%Y-%U')" >> $GITHUB_OUTPUT | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker images cache | |
id: docker_cache | |
uses: actions/cache@v4 | |
with: | |
path: .github/.docker-cache | |
key: ${{ runner.os }}-docker-${{ steps.datetime.outputs.year_week }}-${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-docker-${{ steps.datetime.outputs.year_week }} | |
- name: Load Docker cache (if cache was hit) | |
run: | | |
[ ! -f ${CACHE_PATH}/images.tar ] || docker load -i ${CACHE_PATH}/images.tar | |
- name: Build the Docker image | |
run: docker build . -t sfgrp/taxonworks:latest --build-arg REVISION=$(echo $GITHUB_SHA | cut -c1-9) --build-arg BUNDLER_WORKERS=3 | |
- name: Run image tests | |
run: .github/docker-tests/test.sh | |
- name: Wait build workflow to complete successfully | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const suiteId = ( | |
await github.rest.checks.listForRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: process.env.REF_SHA, | |
check_name: 'build (0)' | |
}) | |
).data.check_runs[0].check_suite.id | |
const oneMinute = () => { | |
return new Promise(resolve => { | |
setTimeout(() => resolve(true), 60000) | |
}) | |
} | |
let suite, attempts = 20 | |
do { | |
core.info(`Checking suite completed successfully (${attempts} remaining). [check_suite_id = ${suiteId}]`) | |
suite = ( | |
await github.rest.checks.getSuite({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
check_suite_id: suiteId | |
}) | |
).data | |
} while(attempts-- && suite.status !== 'completed' && await oneMinute()) | |
if (suite.conclusion !== 'success') { | |
core.setFailed(`Build workflow did not complete successfully. [status = '${suite.status}'; conclusion = '${suite.conclusion}']`); | |
} | |
- name: Login to DockerHub | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Get tag for docker image | |
id: docker_tag | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
return context.ref.startsWith('refs/tags/v') ? context.ref.replace('refs/tags/v', '') : 'latest' | |
- name: Push image to DockerHub | |
if: ${{ github.event_name != 'pull_request' }} | |
env: | |
DOCKER_TAG: '${{steps.docker_tag.outputs.result}}' | |
run: | | |
docker tag sfgrp/taxonworks:latest sfgrp/taxonworks:$DOCKER_TAG | |
docker push sfgrp/taxonworks:$DOCKER_TAG | |
- name: Save Docker cache (if cache was NOT hit) | |
env: | |
CACHE_HASH: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }} | |
run: | | |
mkdir -p $CACHE_PATH | |
[ -f ${CACHE_PATH}/${CACHE_HASH} ] || (\ | |
rm -f ${CACHE_PATH}/images.tar && \ | |
docker save -o ${CACHE_PATH}/images.tar $(docker history -q sfgrp/taxonworks | grep -v '^<missing>') \ | |
) | |
touch ${CACHE_PATH}/${CACHE_HASH} |