-
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.
- Loading branch information
Showing
6 changed files
with
39 additions
and
342 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,120 +1,28 @@ | ||
# SPDX-license-identifier: Apache-2.0 | ||
############################################################################## | ||
# Copyright (c) 2025 | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Apache License, Version 2.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
############################################################################## | ||
name: Create and publish Docker image | ||
# yamllint disable-line rule:truthy | ||
name: Build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "master" | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- "master" | ||
env: | ||
REGISTRY: ghcr.io | ||
REGISTRY: containers.openwow.dev | ||
IMAGE_NAME: ${{ github.repository }} | ||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
if: >- | ||
( github.event_name == 'pull_request_review' && github.event.review.state == 'approved' ) || github.event_name != 'pull_request_review' | ||
outputs: | ||
golang: ${{ steps.filter.outputs.golang }} | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # 3.0.2 | ||
if: ${{ !env.ACT }} | ||
id: filter | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
filters: | | ||
golang: | ||
- '**.go' | ||
code-coverage: | ||
name: Check code coverage | ||
if: needs.changes.outputs.golang == 'true' | ||
needs: changes | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
- uses: gwatts/go-coverage-action@2845595538a59d63d1bf55f109c14e104c6f7cb3 # 2.0.0 | ||
with: | ||
coverage-threshold: 40 | ||
unit-test: | ||
name: Check Go lang unit tests | ||
if: needs.changes.outputs.golang == 'true' | ||
needs: changes | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # 5.3.0 | ||
with: | ||
go-version: "^1.24" | ||
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # 4.2.0 | ||
if: ${{ !env.ACT }} | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- uses: GoTestTools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # 2.2.0 | ||
- name: Run tests | ||
run: | | ||
set -euo pipefail | ||
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
- name: Upload test log | ||
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # 4.6.0 | ||
if: ${{ !env.ACT }} | ||
with: | ||
name: test-log | ||
path: /tmp/gotest.log | ||
if-no-files-found: error | ||
push-registry: | ||
name: Push Docker image to Docker Hub | ||
build: | ||
name: Build and publish Docker image | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
attestations: write | ||
id-token: write | ||
needs: [code-coverage, unit-test] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
- uses: actions/checkout@v4 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 3.3.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # 5.6.1 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # 6.13.0 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Generate artifact attestation | ||
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # 2.2.0 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true | ||
run: | | ||
echo ${{ secrets.GITHUB_TOKEN }} | docker login containers.openwow.dev -u ${{ github.actor }} --password-stdin | ||
- name: Build Docker image | ||
run: | | ||
docker build . -t $REGISTRY/${{ github.repository }}:latest | ||
docker push $REGISTRY/${{ github.repository }}:latest |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.