Skip to content

Commit

Permalink
Add automatic docker image creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Jun 1, 2024
1 parent 01aabd9 commit 581e915
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Builds a docker image when a commit is made. Also pushes the build if the branch is 'master' or 'development'.

# Tag pattern
# 'master' - latest
# 'experimental' - experimental

name: Build and push docker (push/pull request)

on:
workflow_dispatch:
push:
branches:
- master
- experimental
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

env:
DOCKER_PLATFORMS: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64

jobs:
test-build-on-pull-request:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Set SPS_ALSA_EXPLORE_BRANCH env
run: |
SPS_ALSA_EXPLORE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current SPS_ALSA_EXPLORE_BRANCH set to ${SPS_ALSA_EXPLORE_BRANCH}"
echo "SPS_ALSA_EXPLORE_BRANCH=${SPS_ALSA_EXPLORE_BRANCH}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Build
uses: docker/[email protected]
with:
context: ./
file: ./Dockerfile
push: false
build-args: |
SPS_ALSA_EXPLORE_BRANCH=${{ env.SPS_ALSA_EXPLORE_BRANCH }}
build-and-publish:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set SPS_ALSA_EXPLORE_BRANCH env.
run: echo "SPS_ALSA_EXPLORE_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Is branch "master"?
if: ${{ env.SPS_ALSA_EXPLORE_BRANCH == 'master' }}
run: |
echo "IMAGE_TAG_BASE=latest" >> $GITHUB_ENV
- name: Is branch "experimental"?
if: ${{ env.SPS_ALSA_EXPLORE_BRANCH == 'experimental' }}
run: |
echo "IMAGE_TAG_BASE=experimental" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to Docker Registry
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PERSONAL_ACCESS_TOKEN }}

- name: Build and push
uses: docker/[email protected]
with:
context: ./
file: ./Dockerfile
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ env.IMAGE_TAG_BASE != '' }}
tags: ${{ 'mikebrady/sps-alsa-explore' }}:${{ env.IMAGE_TAG_BASE }}
build-args: |
SPS_ALSA_EXPLORE_BRANCH=${{ env.SPS_ALSA_EXPLORE_BRANCH }}

0 comments on commit 581e915

Please sign in to comment.