-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve GitHub Actions #329
Changes from all commits
30cbeaf
c4941f3
d233b35
33b96f3
953e956
4004cfa
353ce08
b697d34
ac3e1d1
8f88421
cf5944a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,104 @@ | ||||||||||||
name: Release | ||||||||||||
|
||||||||||||
on: | ||||||||||||
push: | ||||||||||||
tags: | ||||||||||||
- '[0-9]+.[0-9]+.[0-9]+' | ||||||||||||
|
||||||||||||
jobs: | ||||||||||||
github: | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
steps: | ||||||||||||
- name: Checkout | ||||||||||||
uses: actions/checkout@v4 | ||||||||||||
- name: Create Release | ||||||||||||
uses: actions/create-release@v1 | ||||||||||||
env: | ||||||||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||
with: | ||||||||||||
tag_name: ${{ github.ref_name }} | ||||||||||||
release_name: Version ${{ github.ref_name }} | ||||||||||||
draft: false | ||||||||||||
prerelease: false | ||||||||||||
|
||||||||||||
docker-hub: | ||||||||||||
needs: github | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
env: | ||||||||||||
IMAGE: danihodovic/celery-exporter | ||||||||||||
permissions: | ||||||||||||
contents: write | ||||||||||||
packages: write | ||||||||||||
steps: | ||||||||||||
- name: Checkout | ||||||||||||
uses: actions/checkout@v4 | ||||||||||||
- name: Prepare Image Metadata | ||||||||||||
id: metadata | ||||||||||||
uses: docker/metadata-action@v5 | ||||||||||||
with: | ||||||||||||
images: | | ||||||||||||
${{ env.IMAGE }} | ||||||||||||
ghcr.io/${{ env.IMAGE }} | ||||||||||||
- name: Set Up QEMU | ||||||||||||
uses: docker/setup-qemu-action@v3 | ||||||||||||
- name: Set Up Docker Buildx | ||||||||||||
uses: docker/setup-buildx-action@v3 | ||||||||||||
- name: Login To Docker Hub | ||||||||||||
uses: docker/login-action@v3 | ||||||||||||
with: | ||||||||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||||||||||||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||||||||||||
Comment on lines
+49
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to set |
||||||||||||
- name: Login to Container Registry | ||||||||||||
uses: docker/login-action@v3 | ||||||||||||
with: | ||||||||||||
registry: ghcr.io | ||||||||||||
username: ${{ github.actor }} | ||||||||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||
- name: Build, tag, and push image to Docker Hub | ||||||||||||
uses: docker/build-push-action@v6 | ||||||||||||
with: | ||||||||||||
cache-from: type=gha | ||||||||||||
cache-to: type=gha,mode=max | ||||||||||||
context: . | ||||||||||||
platforms: linux/amd64,linux/arm64 | ||||||||||||
push: true | ||||||||||||
annotations: ${{ steps.metadata.outputs.annotations }} | ||||||||||||
labels: ${{ steps.metadata.outputs.labels }} | ||||||||||||
tags: ${{ steps.metadata.outputs.tags }} | ||||||||||||
- name: Update Description On Docker Hub Description | ||||||||||||
uses: peter-evans/dockerhub-description@v4 | ||||||||||||
with: | ||||||||||||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||||||||||||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||||||||||||
repository: ${{ env.IMAGE }} | ||||||||||||
Comment on lines
+68
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||
|
||||||||||||
helm-chart: | ||||||||||||
runs-on: ubuntu-latest | ||||||||||||
needs: github | ||||||||||||
permissions: | ||||||||||||
contents: write | ||||||||||||
steps: | ||||||||||||
- name: Checkout | ||||||||||||
uses: actions/checkout@v4 | ||||||||||||
with: | ||||||||||||
fetch-depth: 0 | ||||||||||||
- name: Configure Git | ||||||||||||
run: | | ||||||||||||
git config user.name "$GITHUB_ACTOR" | ||||||||||||
git config user.email "[email protected]" | ||||||||||||
- name: Set Up Helm | ||||||||||||
uses: azure/[email protected] | ||||||||||||
with: | ||||||||||||
version: v3.14.4 | ||||||||||||
- name: Get Chart Version | ||||||||||||
id: chart-version | ||||||||||||
run: echo "::set-output name=version::$(grep 'version:' ./charts/celery-exporter/Chart.yaml | cut -d ' ' -f 2)" | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basic test that this works ... $ ls -l ./charts/*
total 24
-rw-r--r-- 1 Kingori staff 333 Oct 17 04:22 Chart.yaml
-rw-r--r-- 1 Kingori staff 2790 Oct 16 18:57 README.md
drwxr-xr-x 3 Kingori staff 96 Oct 16 18:57 ci
drwxr-xr-x 10 Kingori staff 320 Oct 16 18:57 templates
-rw-r--r-- 1 Kingori staff 2640 Oct 16 18:57 values.yaml
$ grep 'version:' ./charts/celery-exporter/Chart.yaml | cut -d ' ' -f 2
0.7.0 |
||||||||||||
- name: Package Helm chart | ||||||||||||
run: helm package ./charts/celery-exporter --app-version=${{ github.ref_name }} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local test that this works ... $ helm package ./charts/celery-exporter --app-version=0.10.13
Successfully packaged chart and saved it to: /Users/Kingori/Repositories/itskingori/celery-exporter/celery-exporter-0.7.0.tgz |
||||||||||||
- name: Upload To Github Release | ||||||||||||
uses: softprops/action-gh-release@v2 | ||||||||||||
with: | ||||||||||||
files: | | ||||||||||||
celery-exporter-${{ steps.chart-version.outputs.version }}.tgz | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be available after packaging ... $ helm package ./charts/celery-exporter --app-version=0.10.13
Successfully packaged chart and saved it to: /Users/Kingori/Repositories/itskingori/celery-exporter/celery-exporter-0.7.0.tgz
$ ls -l celery-exporter-0.7.0.tgz
-rw-r--r-- 1 Kingori staff 4981 Oct 17 04:53 celery-exporter-0.7.0.tgz |
||||||||||||
env: | ||||||||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||
Comment on lines
+93
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating a release for the Helm Chart like this ... celery-exporter/.github/workflows/helm-release.yml Lines 31 to 35 in db019b8
Have it uploaded as an asset to the GitHub release (on tag), because each time we tag we'll get two releases which can be cleaner, here's what we have now ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To note, I removed the preceding
v
for better flexibility in the jobs. This way, in the downstream jobs you can manually prefix where applicable rather than assume it will be everywhere (which it isn't e.g. Docker image tags).