[NM-12] Updated readme #335
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 Docker Image | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
env: | |
TAG_SERVER_DH: mrcide/hintr | |
TAG_WORKER_DH: mrcide/hintr-worker | |
TAG_SERVER_GHCR: hivtools/hintr | |
TAG_WORKER_GHCR: hivtools/hintr-worker | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: extract_branch | |
name: Setup Environment | |
shell: bash | |
run: | | |
if [ "${{github.event_name}}" = "pull_request" ]; | |
then | |
LONG_SHA=${{ github.event.pull_request.head.sha }} | |
echo "CI_BRANCH=${{ github.head_ref }}" >> $GITHUB_OUTPUT | |
else | |
LONG_SHA=${GITHUB_SHA} | |
echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
fi | |
echo "CI_SHA=${LONG_SHA:0:7}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR (GitHub Packages) | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clone Naomi | |
uses: actions/checkout@v4 | |
with: | |
repository: mrc-ide/naomi | |
## ref: feature-branch | |
## ${{ github.token }} is scoped to the current repository, so we | |
## need to provide our own PAT | |
token: ${{ secrets.NAOMI_GH_PAT }} | |
path: naomi | |
- name: Build and push dev containers | |
uses: docker/build-push-action@v5 | |
if: github.event_name == 'pull_request' | |
with: | |
context: . | |
file: "./docker/Dockerfile" | |
push: true | |
tags: | | |
${{env.TAG_SERVER_DH}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
ghcr.io/${{env.TAG_SERVER_GHCR}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
- name: Build and push prod containers | |
uses: docker/build-push-action@v5 | |
if: github.event_name != 'pull_request' | |
with: | |
context: . | |
file: "./docker/Dockerfile" | |
push: true | |
tags: | | |
${{env.TAG_SERVER_DH}}:latest | |
${{env.TAG_SERVER_DH}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
ghcr.io/${{env.TAG_SERVER_GHCR}}:latest | |
ghcr.io/${{env.TAG_SERVER_GHCR}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
- name: Create worker Dockerfile | |
run: | | |
cat << EOF > ./docker/Dockerfile.worker | |
FROM ghcr.io/${{env.TAG_SERVER_GHCR}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
ENTRYPOINT ["/usr/local/bin/hintr_worker"] | |
EOF | |
- name: Build and push dev worker containers | |
uses: docker/build-push-action@v5 | |
if: github.event_name == 'pull_request' | |
with: | |
context: . | |
file: "./docker/Dockerfile.worker" | |
push: true | |
tags: | | |
${{env.TAG_WORKER_DH}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
ghcr.io/${{env.TAG_WORKER_GHCR}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
- name: Build and push prod worker containers | |
uses: docker/build-push-action@v5 | |
if: github.event_name != 'pull_request' | |
with: | |
context: . | |
file: "./docker/Dockerfile.worker" | |
push: true | |
tags: | | |
${{env.TAG_WORKER_DH}}:latest | |
${{env.TAG_WORKER_DH}}:${{steps.extract_branch.outputs.CI_BRANCH}} | |
ghcr.io/${{env.TAG_WORKER_GHCR}}:latest | |
ghcr.io/${{env.TAG_WORKER_GHCR}}:${{steps.extract_branch.outputs.CI_BRANCH}} |