Build, Push Docker Images #518
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, Push Docker Images | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
push: | |
pull_request: | |
# to trigger manually with webhook | |
# curl -X POST https://api.github.com/repos/:owner/:repo/dispatches \ | |
# -H 'Accept: application/vnd.github.everest-preview+json' \ | |
# -H 'Authorization: token TOKEN_VALUE_HERE' \ | |
# --data '{"event_type":"build-push","client_payload":{}}' | |
repository_dispatch: | |
types: [build-push] | |
jobs: | |
build-push: | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
fail-fast: false | |
matrix: | |
image: [ | |
{name: angular-cli, tag: latest, platforms: linux/amd64, build_path: base}, | |
{name: angular-cli, tag: 14.0.6, platforms: linux/amd64, build_path: base, build_args: NG_CLI_VERSION=14.0.6}, | |
{name: aws-cli, tag: latest, platforms: linux/amd64, build_path: latest}, | |
{name: create-react-app, tag: latest, build_path: latest}, | |
{name: duplicity, tag: latest, build_path: base}, | |
{name: ubuntu, tag: 20.04-dind-latest, platforms: linux/amd64, build_path: base}, | |
{name: ubuntu, tag: 20.04-dind-20.10.13, platforms: linux/amd64, build_path: base, build_args: DOCKER_VERSION=20.10.13}, | |
{name: ubuntu, tag: 20.04-dind-19.03.15, platforms: linux/amd64, build_path: base, build_args: DOCKER_VERSION=19.03.15}, | |
#{name: google-cloud-sdk, tag: latest, build_path: base}, | |
{name: httpie-jwt-auth, tag: latest, platforms: linux/amd64, build_path: base, build_args: HTTPIE_JWT_AUTH_VERSION=0.3.0}, | |
{name: httpie-jwt-auth, tag: latest-alpine, platforms: linux/amd64, build_path: base-alpine, build_args: HTTPIE_JWT_AUTH_VERSION=0.3.0}, | |
#{name: jenkins-dod, tag: latest, build_path: latest}, | |
{name: mongo-connector, tag: latest, build_path: base}, | |
{name: node-ruby, tag: latest, platforms: linux/amd64, build_path: base}, | |
{name: packer, tag: latest, build_path: latest}, | |
{name: python-coveralls, tag: latest, build_path: base}, | |
{name: xtrabackup, tag: latest, platforms: linux/amd64, build_path: base}, | |
{name: xtrabackup, tag: "8.0", platforms: linux/amd64, build_path: base, build_args: XTRABACKUP_PACKAGE=percona-xtrabackup-80}, | |
{name: xtrabackup, tag: "2.4", platforms: linux/amd64, build_path: base, build_args: XTRABACKUP_PACKAGE=percona-xtrabackup-24}, | |
{name: xtrabackup, tag: "2.3", platforms: linux/amd64, build_path: base, build_args: XTRABACKUP_PACKAGE=percona-xtrabackup}, | |
{name: xtrabackup, tag: "buster-8.0", platforms: linux/amd64, build_path: base, build_args: XTRABACKUP_PACKAGE=percona-xtrabackup-80 DEBIAN_VERSION=buster}, | |
{name: xtrabackup, tag: "buster-2.4", platforms: linux/amd64, build_path: base, build_args: XTRABACKUP_PACKAGE=percona-xtrabackup-24 DEBIAN_VERSION=buster}, | |
] | |
experimental: [false] | |
# include: | |
# - python: "3.10" | |
# # known issue: https://github.com/nose-devs/nose/issues/1099 | |
# experimental: true | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Normalized env vars | |
id: nev | |
run: | | |
# see: | |
# https://unix.stackexchange.com/questions/105569/bash-replace-space-with-new-line | |
# https://trstringer.com/github-actions-multiline-strings/ | |
echo "BUILD_ARGS<<EOF" >> $GITHUB_ENV | |
echo $BUILD_ARGS | tr " " "\n" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
# enabled to push docker image on git commit on the master branch by default | |
if [ -z "$PUSH_ENABLED" ]; then | |
PUSH_ENABLED=true | |
fi | |
echo "::set-output name=push_enabled::${PUSH_ENABLED}" | |
env: | |
BUILD_ARGS: "${{ matrix.image.build_args }}" | |
PUSH_ENABLED: ${{ secrets.PUSH_ENABLED }} | |
- name: Login to Docker registries | |
if: github.event_name != 'pull_request' | |
uses: teracyhq-incubator/.github/actions/docker-multiple-login-develop@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} | |
#gcr-json-key-base64: ${{ secrets.GCP_KEY_FILE_BASE64 }} | |
- name: Build, Push ${{ matrix.image.name }} ${{ matrix.image.tag }} | |
uses: teracyhq-incubator/.github/actions/docker-build-push-sign-develop@main | |
with: | |
meta-tags: | | |
type=raw,value=${{ matrix.image.tag }} | |
meta-registries: ${{ secrets.REGISTRIES }} | |
meta-image-name: "${{secrets.IMG_NAME_PREFIX}}${{matrix.image.name}}" | |
build-context: ./${{ matrix.image.name }}/${{ matrix.image.build_path}} | |
build-args: ${{ env.BUILD_ARGS }} | |
build-platforms: ${{ matrix.image.platforms }} | |
push-enabled: ${{ steps.nev.outputs.push_enabled == 'true' && github.event_name != 'pull_request' && github.ref_name == 'master' }} |