Skip to content

Commit 33250b7

Browse files
author
Gary Miller
committed
gha to build and push a new docker release, if ohmjs/ohm:VERSION doesn't exist
1 parent 15fe7fa commit 33250b7

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Docker Release
2+
3+
# only run this on merge to main
4+
# clone the repo
5+
# set the VERSION environment variable ie `cat packages/runtime/package.json | jq -r '.version'`
6+
# use `docker manifest inspect ohmjs/ohm:$VERION` to verify that the release doesn't already exist before running the rest of the workflow
7+
# create a multi platfrom builder
8+
# build and push the image
9+
10+
on:
11+
push:
12+
branches: [main]
13+
workflow_dispatch:
14+
inputs:
15+
VERSION:
16+
description: 'Docker image version to build and push'
17+
required: false
18+
19+
jobs:
20+
docker:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Get version
27+
id: version
28+
run: |
29+
if [ -n "${{ inputs.VERSION }}" ]; then
30+
echo "VERSION=${{ inputs.VERSION }}" >> "$GITHUB_OUTPUT"
31+
else
32+
echo "VERSION=$(cat packages/runtime/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
33+
fi
34+
35+
- name: Check if image already exists
36+
id: check
37+
run: |
38+
if docker manifest inspect ohmjs/ohm:${{ steps.version.outputs.VERSION }} > /dev/null 2>&1; then
39+
echo "exists=true" >> "$GITHUB_OUTPUT"
40+
else
41+
echo "exists=false" >> "$GITHUB_OUTPUT"
42+
fi
43+
44+
- name: Set up QEMU
45+
if: steps.check.outputs.exists == 'false'
46+
uses: docker/setup-qemu-action@v4
47+
48+
- name: Set up Docker Buildx
49+
if: steps.check.outputs.exists == 'false'
50+
uses: docker/setup-buildx-action@v4
51+
52+
- name: Log in to Docker Hub
53+
if: steps.check.outputs.exists == 'false'
54+
uses: docker/login-action@v4
55+
with:
56+
username: ${{ secrets.DOCKERHUB_USERNAME }}
57+
password: ${{ secrets.DOCKERHUB_TOKEN }}
58+
59+
- name: Build and push
60+
if: steps.check.outputs.exists == 'false'
61+
uses: docker/bake-action@v7
62+
with:
63+
files: docker/docker-compose.yml
64+
push: true
65+
env:
66+
VERSION: ${{ steps.version.outputs.VERSION }}

0 commit comments

Comments
 (0)