-
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.
chore: Update various github workflows (#100)
* add title to release * run helm docs in the pr & use github env * use the centrazlied image build process we use internally --------- Co-authored-by: jamie zieziula <[email protected]>
- Loading branch information
1 parent
e9eda34
commit 38593d8
Showing
7 changed files
with
209 additions
and
123 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,58 @@ | ||
--- | ||
name: Build and push image | ||
|
||
"on": | ||
workflow_call: | ||
inputs: | ||
environment: | ||
description: Determines which docker registry credentials to use | ||
required: true | ||
type: string | ||
image: | ||
description: Image name (without the tag & registry) | ||
required: true | ||
type: string | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
build_push_image: | ||
name: Build and push image | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
# These credentials are managed in Terraform. Depending on the 'environment' value above, | ||
# these will either be the credentials for 'dev' or 'prod'. | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Docker image metadata | ||
id: metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: prefecthq/${{ inputs.image }} | ||
tags: | | ||
type=ref,event=pr | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
labels: | | ||
org.opencontainers.image.title=prefect-operator | ||
org.opencontainers.image.description=Prefect Operator image | ||
org.opencontainers.image.vendor=Prefect | ||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |
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 @@ | ||
--- | ||
name: Build and push images for merges to main | ||
|
||
"on": | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- api/** | ||
- cmd/** | ||
- internal/** | ||
- Dockerfile | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
run_unit_tests: | ||
uses: ./.github/workflows/tests.yaml | ||
permissions: | ||
# required by downstream jobs | ||
contents: read | ||
|
||
build_and_push_image_for_main: | ||
needs: run_unit_tests | ||
uses: ./.github/workflows/build-and-push-image.yaml | ||
with: | ||
environment: dev | ||
image: prefect-operator-dev |
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,35 @@ | ||
--- | ||
name: Build and push images for pull requests | ||
|
||
"on": | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- api/** | ||
- cmd/** | ||
- internal/** | ||
- Dockerfile | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
run_unit_tests: | ||
uses: ./.github/workflows/tests.yaml | ||
permissions: | ||
# required by downstream jobs | ||
contents: read | ||
|
||
build_and_push_image_for_prs: | ||
needs: run_unit_tests | ||
if: contains(github.event.pull_request.labels.*.name, 'build-image') | ||
uses: ./.github/workflows/build-and-push-image.yaml | ||
with: | ||
environment: dev | ||
image: prefect-operator-dev |
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,70 @@ | ||
--- | ||
name: Build and push images for tags | ||
|
||
"on": | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
run_unit_tests: | ||
uses: ./.github/workflows/tests.yaml | ||
permissions: | ||
# required by downstream jobs | ||
contents: read | ||
|
||
build_and_upload_manifests: | ||
needs: run_unit_tests | ||
permissions: | ||
# required to write artifacts to a release | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install tool dependencies | ||
uses: jdx/mise-action@v2 | ||
with: | ||
experimental: true | ||
|
||
- name: Package kubernetes manifests & CRDs | ||
run: | | ||
# package just CRDs | ||
cat deploy/charts/prefect-operator/crds/*.yaml > prefect-crds.yaml | ||
make helmbuild | ||
# template the helm chart including the CRDs | ||
helm template prefect-operator deploy/charts/prefect-operator \ | ||
--include-crds --set operator.image.tag=${{ github.ref_name }} \ | ||
> prefect-operator.yaml | ||
# Remove labels relevant only for Helm installs | ||
yq -i 'del(.metadata.labels."app.kubernetes.io/managed-by")' prefect-operator.yaml | ||
yq -i 'del(.metadata.labels."helm.sh/chart")' prefect-operator.yaml | ||
yq -i 'del(.spec.template.metadata.labels."app.kubernetes.io/managed-by")' prefect-operator.yaml | ||
yq -i 'del(.spec.template.metadata.labels."helm.sh/chart")' prefect-operator.yaml | ||
# Ensure all references to app version match the released version tag | ||
yq -i '(.. | select(tag == "!!str" and . == "v0.0.0")) |= "${{ github.ref_name }}"' prefect-operator.yaml | ||
- name: Upload release assets | ||
run: gh release upload ${{ github.ref_name }} prefect-crds.yaml prefect-operator.yaml | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
|
||
build_and_push_image_for_tags: | ||
needs: run_unit_tests | ||
uses: ./.github/workflows/build-and-push-image.yaml | ||
with: | ||
environment: prod | ||
image: prefect-operator | ||
|
||
create_helm_release: | ||
needs: build_and_push_image_for_tags | ||
uses: ./.github/workflows/helm-release.yaml | ||
permissions: | ||
# required by downstream jobs | ||
contents: write | ||
# this is required so that the workflow can read secrets | ||
# from the environment | ||
secrets: inherit |
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