Skip to content

Update depot-build.yml #9

Update depot-build.yml

Update depot-build.yml #9

Workflow file for this run

# based on: https://depot.dev/docs/integrations/github-actions#build-multi-platform-images-natively-without-emulation
# see docs at: https://github.com/depot/build-push-action
# note: could also use a more direct approach based on the depot CLI, which is more like that used for the depot-bitbucket integration
# and also more similar to the native `docker buildx build` CLI (in fact they've deliberately set it up to accept the same CLI options):
# CLI approach for Bitbucket (docker build): https://depot.dev/docs/integrations/bitbucket-pipelines#basic-build-and-push-to-dockerhub
# CLI approach for GitHub (generic): https://depot.dev/docs/integrations/github-actions#option-3--depot-cli
name: depot-build
on:
# you need to set workflow_dispatch to be able to run it manually:
# https://stackoverflow.com/a/67523883/4070848
workflow_dispatch: {}
push:
# have included both main and master only to prevent an issue if using this yml in a repo where the other branch name is used...
branches:
- main
- master
# reduce the number of builds by limiting automatic builds being triggered only with a push to *this* yml file (e.g. to change the docker tag version number):
# can trigger a build manually too via: https://github.com/drmrbrewer/astro-api/actions/workflows/depot-build.yml
paths:
- '.github/workflows/depot-build.yml'
# - 'Dockerfile-captain'
# - 'captain-apache2.conf'
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
# these secrets are set at repository level:
# https://github.com/drmrbrewer/astro-api/settings/secrets/actions
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: depot/build-push-action@v1
with:
# these secrets are set at repository level:
project: ${{ secrets.DEPOT_PROJECT_ID }}
token: ${{ secrets.DEPOT_PROJECT_TOKEN }}
# what tags to apply to the generated image:
# the images will be pushed to: https://hub.docker.com/repository/docker/drmrbrewer/astro-api/general
tags: drmrbrewer/astro-api,drmrbrewer/astro-api:v22
# base folder for the build (equivalent to PATH in docker buildx build)...
# commented out for now as the docker image seems to be much smaller without it...
# context: .
# this is a multi-platform build... specify required platforms here:
platforms: linux/amd64,linux/arm64
# which (of several) Dockerfiles to use for the build:
file: "Dockerfile-captain"
# push to the Docker Hub (login credentials set above):
push: true
# following is to avoid an 'unknown/unknown' entry for 'OS/arch' showing (in addition to the ones you ask for) in the registry UI (probably just cosmetic, but annoying):
# https://github.com/orgs/community/discussions/45969
# https://docs.docker.com/build/attestations/#creating-attestations
provenance: false