Skip to content

feat(github-action): update fluxcd/flux2 ( v2.3.0 → v2.4.0 ) (#1864) #1103

feat(github-action): update fluxcd/flux2 ( v2.3.0 → v2.4.0 ) (#1864)

feat(github-action): update fluxcd/flux2 ( v2.3.0 → v2.4.0 ) (#1864) #1103

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Publish OCI artifact"
on:
workflow_dispatch: {}
push:
branches:
- main
paths:
- .github/workflows/oci.yaml
- kubernetes/**
# Default GITHUB_TOKEN token permissions do NOT support cosign and must be enabled.
# This is to set the package and id_token permissions to read|write.
# Current default permissions can be viewed here: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions: write-all
env:
OCI_REPO: "oci://ghcr.io/xunholy/manifests/${{ github.event.repository.name }}"
GHCR_REPO: "ghcr.io/xunholy/manifests/${{ github.event.repository.name }}"
jobs:
publish:
runs-on: ubuntu-latest
env:
COSIGN_EXPERIMENTAL: "true"
COSIGN_YES: "true"
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create OCI artifact
run: |
flux push artifact "$OCI_REPO:$(git rev-parse --short HEAD)" \
--path="./kubernetes" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git branch --show-current)@sha1:$(git rev-parse HEAD)"
- name: Create OCI artifact tag
run: |
flux tag artifact "$OCI_REPO:$(git rev-parse --short HEAD)" --tag main
- uses: imjasonh/setup-crane@31b88efe9de28ae0ffa220711af4b60be9435f6e # v0.4
- uses: sigstore/cosign-installer@main
- name: Get the digest of the OCI artifact
id: crane
run: |
DIGEST=$(crane digest "$GHCR_REPO:$(git rev-parse --short HEAD)")
echo "DIGEST=$DIGEST" >> $GITHUB_OUTPUT
- name: Sign the OCI artifact
run: cosign sign "$GHCR_REPO@${{ steps.crane.outputs.DIGEST }}" -y