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 b60a315
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 87 deletions.
70 changes: 17 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,29 @@ name: build-containers
on:
push:
branches:
- master
- main
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: docker/#-action@v3

- uses: actions/setup-go@v5
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
go-version: stable

- uses: ko-build/setup-ko@v0.6

- name: Log in to GHCR
uses: docker/#-action@v2
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: Co#staller
# 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 "action@github.com"
git config --local user.name "GitHub Actions"
registry: ghcr.io
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 b60a315

Please # to comment.