Skip to content

Commit

Permalink
build: build & publish with ko
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Jun 27, 2024
1 parent f4e1870 commit 22601cc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 86 deletions.
73 changes: 21 additions & 52 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,34 @@ name: build-containers
on:
push:
branches:
- master
- main

permissions:
contents: read
packages: write

jobs:
vultr-exporter:
build-publish:
name: updown-exporter
runs-on: ubuntu-latest
env:
REPO: dazwilkin/updown-exporter
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: docker/setup-buildx-action@v3
- name: Login

- uses: actions/setup-go@v5
with:
go-version: stable

- uses: ko-build/[email protected]

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR }}
- name: Get kernel version
run: echo "VERSION=$(uname --kernel-release)" >> ${GITHUB_ENV}
- name: Exporter
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
build-args: |
TOKEN=${{ secrets.GHCR }}
VERSION=${{ env.VERSION }}
COMMIT=${{ github.sha }}
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }}
push: true
# - name: Cosign installer
# uses: sigstore/cosign-installer@main
# - name: Write signing key to disk (only needed for `cosign sign --key`)
# run: echo "${{ secrets.SIGNING }}" > ./cosign.key
# - name: Sign container image
# run: |
# cosign sign \
# --key=./cosign.key \
# --annotations="repo=${{ github.repository }}" \
# --annotations="workflow=${{ github.workflow }}" \
# --annotations="commit=${{ github.sha }}" \
# --annotations="version=${{ env.VERSION }}" \
# ghcr.io/${{ env.REPO }}:${{ github.sha }}
# env:
# COSIGN_PASSWORD: ""
- name: Revise occurrences of the image
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

for FILENAME in "./README.md"
do
echo "Replacing: ${REPO}"
sed \
--in-place \
"s|${{ env.REPO }}:[0-9a-f]\{40\}|${{ env.REPO }}:${{ github.sha }}|g" \
${FILENAME}
git add ${FILENAME}
done
git commit --message "GitHub Actions update image references"
git push origin master
- run: |
ko build --sbom=none --bare .
env:
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
10 changes: 10 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
builds:
- id: updown-exporter
main: .
ldflags:
- -s -w
- -extldflags "-static"

defaultPlatforms:
- linux/arm64
- linux/amd64
34 changes: 0 additions & 34 deletions Dockerfile

This file was deleted.

0 comments on commit 22601cc

Please sign in to comment.