forked from 2i2c-org/frx-challenges
-
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.
Add setup files and actions for chartpress
- Loading branch information
1 parent
cecae08
commit 9b6e50d
Showing
3 changed files
with
167 additions
and
0 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,122 @@ | ||
# This is a GitHub workflow defining a set of jobs with a set of steps. | ||
# ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | ||
# | ||
name: Publish chart | ||
|
||
# Trigger the workflow on pushed tags or commits to main branch. | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- "docs/**" | ||
- "**.md" | ||
- ".github/workflows/*" | ||
- "!.github/workflows/publish-chart.yaml" | ||
push: | ||
paths-ignore: | ||
- "docs/**" | ||
- "**.md" | ||
- ".github/workflows/*" | ||
- "!.github/workflows/publish-chart.yaml" | ||
branches-ignore: | ||
- "dependabot/**" | ||
- "pre-commit-ci-update-config" | ||
tags: | ||
- "**" | ||
|
||
jobs: | ||
# Packages the Helm chart, and pushes it to 2i2c-org/unnamed-thingity-thing@gh-pages. | ||
# | ||
publish: | ||
runs-on: ubuntu-22.04 | ||
|
||
# Explicitly request permissions to push to this git repository's gh-pages | ||
# branch via the the GITHUB_TOKEN we can have access to. | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# chartpress needs git history | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Decide to publish or not | ||
id: publishing | ||
shell: python | ||
run: | | ||
import os | ||
repo = "${{ github.repository }}" | ||
event = "${{ github.event_name }}" | ||
ref = "${{ github.event.ref }}" | ||
publishing = "" | ||
if ( | ||
repo == "2i2c-org/unnamed-thingity-thing" | ||
and event == "push" | ||
and ( | ||
ref.startswith("refs/tags/") | ||
or ref == "refs/heads/main" | ||
) | ||
): | ||
publishing = "true" | ||
print("Publishing chart") | ||
with open(os.environ["GITHUB_OUTPUT"], "a") as f: | ||
f.write(f"publishing={publishing}\n") | ||
- name: Set up QEMU (for docker buildx) | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx (for chartpress multi-arch builds) | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Setup push rights to Quay.io | ||
if: steps.publishing.outputs.publishing | ||
run: | | ||
docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io | ||
- name: Install dependencies | ||
run: | | ||
pip install -r dev-requirements.txt | ||
pip list | ||
helm version | ||
- name: Configure a git user | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions user" | ||
- name: Build image, push if necessary | ||
env: | ||
PUBLISHING: ${{ steps.publishing.outputs.publishing }} | ||
run: | | ||
CHARTPRESS_ARGS="" | ||
if [[ "${PUBLISHING}" == "true" ]]; then | ||
CHARTPRESS_ARGS="--push" | ||
fi | ||
chartpress \ | ||
--builder docker-buildx \ | ||
--platform linux/amd64 --platform linux/arm64 \ | ||
${CHARTPRESS_ARGS} | ||
- name: Publish chart with chartpress | ||
if: steps.publishing.outputs.publishing | ||
env: | ||
GITHUB_TOKEN: "${{ github.token }}" | ||
run: | | ||
set -eux | ||
PUBLISH_ARGS="--publish-chart --push" | ||
if [[ $GITHUB_REF != refs/tags/* ]]; then | ||
PR_OR_HASH=$(git log -1 --pretty=%h-%B | head -n1 | sed 's/^.*\(#[0-9]*\).*/\1/' | sed 's/^\([0-9a-f]*\)-.*/@\1/') | ||
LATEST_COMMIT_TITLE=$(git log -1 --pretty=%B | head -n1) | ||
EXTRA_MESSAGE="${{ github.repository }}${PR_OR_HASH} ${LATEST_COMMIT_TITLE}" | ||
chartpress $PUBLISH_ARGS --extra-message "${EXTRA_MESSAGE}" | ||
else | ||
chartpress $PUBLISH_ARGS --tag "${GITHUB_REF:10}" | ||
fi | ||
git --no-pager diff --color |
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,37 @@ | ||
# This is the configuration for chartpress, a CLI for Helm chart management. | ||
# | ||
# chartpress is used to: | ||
# - Build images | ||
# - Update Chart.yaml (version) and values.yaml (image tags) | ||
# - Package and publish Helm charts to a GitHub based Helm chart repository | ||
# | ||
# For more information, see the projects README.md file: | ||
# https://github.com/jupyterhub/chartpress | ||
# | ||
|
||
# This is the configuration for chartpress, a CLI for Helm chart management. | ||
# | ||
# chartpress is used to: | ||
# - Build images | ||
# - Update Chart.yaml (version) and values.yaml (image tags) | ||
# - Package and publish Helm charts to a GitHub based Helm chart repository | ||
# | ||
# For more information, see the projects README.md file: | ||
# https://github.com/jupyterhub/chartpress | ||
# | ||
charts: | ||
- name: unnamed | ||
chartPath: helm-chart | ||
imagePrefix: quay.io/2i2c-org/ | ||
# Set dev version by taking latest tag and incrementing patch | ||
baseVersion: patch | ||
|
||
repo: | ||
git: 2i2c-org/unnamed-thingity-thing | ||
published: https://2i2c.org/unnamed-thingity-thing/ | ||
|
||
images: | ||
unnamed: | ||
dockerfilePath: Dockerfile | ||
contextPath: . | ||
valuesPath: image |
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,8 @@ | ||
# chartpress is important for local development, CI and CD | ||
# - builds images and can push them also (--push) | ||
# - updates image names and tags in values.yaml | ||
# - can publish the built Helm chart (--publish) | ||
# | ||
# ref: https://github.com/jupyterhub/chartpress | ||
# | ||
chartpress |