Skip to content

Commit

Permalink
feat(ci): add build docker images workflow
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <[email protected]>
  • Loading branch information
iverly committed Jul 15, 2024
1 parent 4d4ec5a commit f030a4a
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build-docker-images.yaml
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/[email protected]
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 }}

0 comments on commit f030a4a

Please sign in to comment.