-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
8075c09
commit d4007c5
Showing
8 changed files
with
193 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Nightly Release | ||
|
||
on: | ||
workflow_dispatch: # Manual trigger | ||
schedule: | ||
- cron: '0 5 * * *' # 5 AM UTC = Midnight EST | ||
pull_request: | ||
|
||
jobs: | ||
nightly: | ||
if: ${{ github.repository == 'liangyuanpeng/shipwright-triggers' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # To be able to get OIDC ID token to sign images. | ||
contents: write # To be able to update releases. | ||
packages: write # To be able to push images and signatures. | ||
|
||
env: | ||
IMAGE_HOST: ghcr.io | ||
IMAGE_NAMESPACE: ${{ github.repository }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.19.x' | ||
check-latest: true | ||
|
||
# Install tools | ||
- uses: ko-build/[email protected] | ||
with: | ||
version: v0.13.0 | ||
- uses: imjasonh/setup-crane@e82f1b9a8007d399333baba4d75915558e9fb6a4 | ||
- uses: sigstore/cosign-installer@v3 | ||
|
||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d-%s')" >> $GITHUB_OUTPUT | ||
|
||
- name: Generate and upload release YAMLs | ||
env: | ||
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_USERNAME: ${{ github.repository_owner }} | ||
TAG: "nightly-${{ steps.date.outputs.date }}" | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
make release | ||
mv release.yaml nightly-${{ steps.date.outputs.date }}.yaml | ||
mv release-debug.yaml nightly-${{ steps.date.outputs.date }}-debug.yaml | ||
# gh release upload nightly nightly-${{ steps.date.outputs.date }}.yaml | ||
# gh release upload nightly nightly-${{ steps.date.outputs.date }}-debug.yaml | ||
|
||
- name: Update latest tag of supporting images | ||
run: | | ||
crane copy "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:nightly-${{ steps.date.outputs.date }}" "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:latest" | ||
- name: Sign released images | ||
run: | | ||
for f in \ | ||
nightly-${{ steps.date.outputs.date }}.yaml \ | ||
nightly-${{ steps.date.outputs.date }}-debug.yaml; do | ||
grep -o "ghcr.io[^\"]*" $f | xargs cosign sign --yes \ | ||
-a sha=${{ github.sha }} \ | ||
-a run_id=${{ github.run_id }} \ | ||
-a run_attempt=${{ github.run_attempt }} | ||
done |
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: shipwright-build |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: shipwright-triggers | ||
subjects: | ||
- kind: ServiceAccount | ||
name: shipwright-triggers | ||
namespace: shipwright-build | ||
roleRef: | ||
kind: ClusterRole | ||
name: shipwright-triggers | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: shipwright-triggers | ||
namespace: shipwright-build | ||
subjects: | ||
- kind: ServiceAccount | ||
name: shipwright-triggers | ||
namespace: shipwright-build | ||
roleRef: | ||
kind: Role | ||
name: shipwright-triggers | ||
apiGroup: rbac.authorization.k8s.io |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: shipwright-triggers | ||
namespace: shipwright-build |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: shipwright-triggers | ||
namespace: shipwright-build | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: shipwright-triggers | ||
template: | ||
metadata: | ||
labels: | ||
name: shipwright-triggers | ||
spec: | ||
serviceAccountName: shipwright-triggers | ||
containers: | ||
- name: shipwright-trigger | ||
image: ko://github.com/shipwright-io/triggers | ||
env: | ||
- name: WATCH_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: BUILD_CONTROLLER_LEADER_ELECTION_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: CONTROLLER_NAME | ||
value: "shipwright-build" | ||
- name: GIT_ENABLE_REWRITE_RULE | ||
value: "false" | ||
ports: | ||
- containerPort: 8080 | ||
name: metrics-port | ||
livenessProbe: | ||
httpGet: | ||
path: /metrics | ||
port: metrics-port | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
readinessProbe: | ||
httpGet: | ||
path: /metrics | ||
port: metrics-port | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Copyright The Shipwright Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
GO_FLAGS=${GO_FLAGS:-""} | ||
|
||
echo "Logging into container registry $IMAGE_HOST" | ||
echo "$REGISTRY_PASSWORD" | ko login -u "$REGISTRY_USERNAME" --password-stdin "$IMAGE_HOST" | ||
|
||
echo "Building container image" | ||
|
||
echo "Adding io.shipwright.vcs-ref label with value: ${GITHUB_SHA}" | ||
|
||
KO_DOCKER_REPO="${IMAGE_HOST}/${IMAGE_NAMESPACE}" GOFLAGS="${GO_FLAGS}" ko resolve \ | ||
--base-import-paths \ | ||
--tags "${TAG}" \ | ||
--image-label "io.shipwright.vcs-ref=${GITHUB_SHA}" \ | ||
--platform=all -R -f deploy/ > release.yaml | ||
|
||
KO_DOCKER_REPO="${IMAGE_HOST}/${IMAGE_NAMESPACE}" GOFLAGS="${GO_FLAGS} -tags=pprof_enabled" ko resolve \ | ||
--base-import-paths \ | ||
--tags "${TAG}-debug" \ | ||
--image-label "io.shipwright.vcs-ref=${GITHUB_SHA}" \ | ||
--platform=all -R -f deploy/ > release-debug.yaml |