Docker Image CI #11
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: Docker Image CI | |
on: | |
push: | |
branches: [ dev ] | |
workflow_run: | |
workflows: ["Bump version"] | |
types: | |
- completed | |
branches: [main] | |
jobs: | |
buildx: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- | |
name: Get version from git | |
run: echo "RELEASE_VERSION=$(git describe --tags --abbrev=0 | grep -Eo '[0-9]+\.[0-9]+.[0-9]+')" >> $GITHUB_ENV | |
- | |
name: Set release channel for dev | |
run: echo "RELEASE_CHANNEL=-dev" >> $GITHUB_ENV | |
if: ${{ github.ref_name == 'dev' }} | |
- | |
name: Test release tag version and channel | |
run: echo "RELEASE_VERSION == $RELEASE_VERSION CHANNEL == $RELEASE_CHANNEL" | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Authenticate to ghcr | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- | |
name: build options | |
run: echo "tags:" "*.platform=linux/amd64,linux/arm64" "tags=spr-tailscale:${RELEASE_VERSION:-latest}" | |
- | |
name: Build and push containers | |
run: | | |
./build_docker_compose.sh \ | |
--set "*.platform=linux/amd64,linux/arm64" \ | |
--set "*.tags=ghcr.io/spr-networks/spr-tailscale:${RELEASE_VERSION:-latest}" \ | |
--set "*.tags=ghcr.io/spr-networks/spr-tailscale:latest" \ | |
`[[ "${{ github.event_name }}" = "workflow_run" && ("${{ github.ref_name }}" = "main") || ( ! -z $RELEASE_CHANNEL && ("${{ github.event_name }}" = "push")) ]] && echo "--push"` || exit 1 | |
- name: Get images from docker-compose.yml | |
id: get-images | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -o json -I 0 '[.services|.[]|.image]' docker-compose.yml | |
- name: Set Matrix output | |
id: set-matrix | |
run: | | |
echo 'name=matrix::${{ steps.get-images.outputs.result }}' >> $GITHUB_OUTPUT | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} |