-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Build PR images on GHCR (#3432)
* Upgrade CI * Keep lint and test on tags * Keep actions/checkout@v3 * Consider CI on branches named v* * Fix write packages * Distinct Elixir CI and PR Build * Rename build * Fix type * Add workflow_dispatch * Add timeout to prevent stuck jobs * Add actions for buildx and merge * fix username ? * Add grafana images from PR * fix typo * Finih merge action refactoring * Exclude PRs related to .github from auto-run * Don't try to auth on DockerHub when we can't * tmp allow myself to execute * Update ghcr_build.yml to be able to write on packages from public fork * Revert ghcr_build.yml * Update ghcr_build.yml * Update to build on source repo * Update ghcr_build.yml to test * Use correct repo with REGISTRY_IMAGE * Update ghcr_build.yml * Update ghcr_build.yml * Update ghcr_build.yml * Update ghcr_build.yml * Update ghcr_build.yml * Use dynamic variables to work in all repos * Purge in source repo * Update ghcr_build.yml * Update ghcr_build.yml * Update ghcr_build.yml * Update action.yaml * Update ghcr_build.yml * Update buildx.yml * Update action.yaml * Fix vars * Trace digests * Update action.yml * Update action.yml * Fix typo * Fox repo name * Update buildx.yml * Update action.yaml * Fix repository name * Run on any branch pushed * Exclude PRs related to .github from auto-run * Add buildjet dependency * lint * lint actions * fix: links in dashboards --------- Co-authored-by: Julien <[email protected]>
- Loading branch information
Showing
10 changed files
with
307 additions
and
94 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,70 @@ | ||
name: "Build" | ||
description: "Build images" | ||
inputs: | ||
docker_password: | ||
description: "Docker password" | ||
required: true | ||
repository_owner: | ||
description: "Repository owner" | ||
required: true | ||
default: "teslamate-org" | ||
repository: | ||
description: "Repo owner and name (repo_owner/repo_name)" | ||
required: true | ||
default: "teslamate" | ||
github_token: | ||
description: "GitHub Token" | ||
required: true | ||
labels: | ||
description: "Labels added on metadata" | ||
required: false | ||
default: "" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
labels: | | ||
{{ inputs.labels }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
if: inputs.docker_password != '' | ||
uses: docker/[email protected] | ||
with: | ||
username: teslamate | ||
password: ${{ inputs.docker_password }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ inputs.repository_owner }} | ||
password: ${{ inputs.github_token }} | ||
- name: Build and push by digest | ||
id: build | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
platforms: ${{ matrix.platform }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
cache-from: type=registry,ref=ghcr.io/${{ inputs.repository }}:buildcache-${{ matrix.cache_id }} | ||
cache-to: type=registry,ref=ghcr.io/${{ inputs.repository }}:buildcache-${{ matrix.cache_id }},mode=max | ||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | ||
- name: Export digest | ||
shell: bash | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
ls -l /tmp/digests/ | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 |
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 @@ | ||
name: "Grafana" | ||
description: "Grafana images" | ||
inputs: | ||
tags: | ||
description: "Tags" | ||
required: false | ||
default: "" | ||
labels: | ||
description: "Labels" | ||
required: true | ||
image: | ||
description: "Image target" | ||
required: true | ||
default: "teslamate/grafana" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ inputs.image }} | ||
tags: ${{ inputs.tags }} | ||
labels: ${{ inputs.labels }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and push | ||
uses: docker/[email protected] | ||
with: | ||
context: grafana | ||
push: true | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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,40 @@ | ||
name: "Merge" | ||
description: "Merge images" | ||
inputs: | ||
tags: | ||
description: "Tags" | ||
required: false | ||
default: "" | ||
image: | ||
description: "Image target" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ inputs.image }} | ||
tags: ${{ inputs.tags }} | ||
|
||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
shell: bash | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
- name: Inspect image | ||
shell: bash | ||
run: | | ||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
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 |
---|---|---|
|
@@ -31,118 +31,52 @@ jobs: | |
cache_id: arm64 | ||
|
||
runs-on: ${{ matrix.runs_on }} | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
- name: Buildx | ||
uses: ./.github/actions/build | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: teslamate | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push by digest | ||
id: build | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
platforms: ${{ matrix.platform }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
cache-from: type=registry,ref=ghcr.io/teslamate-org/teslamate:buildcache-${{ matrix.cache_id }} | ||
cache-to: type=registry,ref=ghcr.io/teslamate-org/teslamate:buildcache-${{ matrix.cache_id }},mode=max | ||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | ||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
docker_password: ${{ secrets.DOCKER_PASSWORD }} | ||
repository_owner: ${{ github.repository_owner }} | ||
repository: ${{ github.repository }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
teslamate_merge: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- teslamate_build | ||
steps: | ||
- name: Download digests | ||
uses: actions/download-artifact@v3 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
username: teslamate | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- uses: ./.github/actions/merge | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
image: ${{ env.REGISTRY_IMAGE }} | ||
tags: | | ||
type=schedule,pattern=edge | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=edge | ||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: teslamate | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: | | ||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | ||
grafana: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v5 | ||
|
||
- uses: ./.github/actions/grafana | ||
with: | ||
images: teslamate/grafana | ||
tags: | | ||
type=edge | ||
type=schedule,pattern=edge | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to DockerHub | ||
uses: docker/[email protected] | ||
with: | ||
username: teslamate | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build and push | ||
uses: docker/[email protected] | ||
with: | ||
context: grafana | ||
push: true | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64 | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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
Oops, something went wrong.