-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add build docker images workflow
Signed-off-by: iverly <github@iverly.net>
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Build docker images | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/build-docker-images.yaml | ||
- apps/**/Dockerfile | ||
- apps/**/*.Dockerfile | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
docker: | ||
name: docker | ||
concurrency: | ||
group: docker | ||
cancel-in-progress: false | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- name: ha-linky | ||
path: apps/home-assistant | ||
dockerfile: ha-linky.Dockerfile | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Install cosign | ||
uses: sigstore/cosign-installer@v3.5.0 | ||
with: | ||
cosign-release: "v2.2.4" | ||
|
||
- name: Set outputs | ||
id: vars | ||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ steps.vars.outputs.sha_short }} | ||
context: ${{ matrix.path }} | ||
file: ${{ matrix.path }}/${{ matrix.dockerfile }} | ||
platforms: linux/amd64, linux/arm64 | ||
provenance: true | ||
sbom: true | ||
|
||
- name: Sign the images with GitHub OIDC Token | ||
run: | | ||
cosign sign --yes ghcr.io/${{ github.repository }}/${{ matrix.name }}:${{ steps.vars.outputs.sha_short }} |