From 3df37d34d71ce4cb060781569d2eb42e39c2d9b8 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 03:30:00 +0100 Subject: [PATCH 01/53] Upgrade CI --- .github/workflows/elixir.yml | 55 ++++++++++++++++++++++++++++++++++-- .github/workflows/purge.yml | 31 ++++++++++++++++++++ 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/purge.yml diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 0eb62d86c2..22966a8548 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -1,11 +1,60 @@ -name: Elixir CI +name: Elixir CI & PR images on: push: + branches: [ "master" ] pull_request: branches: [ "master" ] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: + build: + name: Build images (only if pull_request) + if: github.event_name == 'pull_request' + strategy: + fail-fast: false + matrix: + include: + - platform: "linux/amd64" + runs_on: "ubuntu-latest" + cache_id: amd64 + - platform: "linux/arm/v7" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm + - platform: "linux/arm64" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm64 + runs-on: ${{ matrix.runs_on }} + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + labels: | + org.opencontainers.image.version=${{ github.ref || github.ref_name }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + lint: name: Lint (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}) runs-on: ubuntu-20.04 @@ -21,7 +70,7 @@ jobs: lint: true steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 id: beam @@ -135,7 +184,7 @@ jobs: ELIXIR_ASSERT_TIMEOUT: 1000 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - uses: erlef/setup-beam@v1 id: beam diff --git a/.github/workflows/purge.yml b/.github/workflows/purge.yml new file mode 100644 index 0000000000..dd03f303b6 --- /dev/null +++ b/.github/workflows/purge.yml @@ -0,0 +1,31 @@ +name: Purge PR images + +on: + pull_request_target: + types: + - closed + +jobs: + purge-pr-untagged: + name: Delete untagged images from ghcr.io + runs-on: ubuntu-latest + + steps: + - uses: actions/delete-package-versions@v4 + with: + package-name: "teslamate" + package-type: "container" + min-versions-to-keep: 0 + delete-only-untagged-versions: "true" + token: ${{ secrets.GITHUB_TOKEN }} + + purge-pr-package: + name: Delete image from ghcr.io + runs-on: ubuntu-latest + + steps: + - uses: chipkent/action-cleanup-package@v1.0.1 + with: + package-name: ${{ github.event.repository.name }} + tag: pr-${{ github.event.pull_request.number }} + github-token: ${{ secrets.GITHUB_TOKEN }} From 66fd7919471010646462559379640ff03ec4135a Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 03:33:59 +0100 Subject: [PATCH 02/53] Keep lint and test on tags --- .github/workflows/elixir.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 22966a8548..c26ba5c908 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -2,7 +2,10 @@ name: Elixir CI & PR images on: push: - branches: [ "master" ] + branches: + - "master" + tags: + - "v*" pull_request: branches: [ "master" ] From 600f4803624c8176af12fdce6bff0998939359c1 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 03:35:19 +0100 Subject: [PATCH 03/53] Keep actions/checkout@v3 --- .github/workflows/elixir.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index c26ba5c908..1011608bc8 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -36,7 +36,7 @@ jobs: packages: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -73,7 +73,7 @@ jobs: lint: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 id: beam @@ -187,7 +187,7 @@ jobs: ELIXIR_ASSERT_TIMEOUT: 1000 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 id: beam From 39861fd8fdfd8b2efb147028a5e3eaf6320aa136 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 03:57:26 +0100 Subject: [PATCH 04/53] Consider CI on branches named v* --- .github/workflows/elixir.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 1011608bc8..0a2e5480ee 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -4,8 +4,9 @@ on: push: branches: - "master" - tags: - "v*" + tags: + - "v*" pull_request: branches: [ "master" ] From 6e7af9612169e1f26a82edec28a04eb645ea44f9 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 04:00:28 +0100 Subject: [PATCH 05/53] Fix write packages --- .github/workflows/elixir.yml | 7 ++++--- .github/workflows/purge.yml | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 0a2e5480ee..d19b449713 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -14,6 +14,10 @@ env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} +permissions: + contents: read + packages: write + jobs: build: name: Build images (only if pull_request) @@ -32,9 +36,6 @@ jobs: runs_on: "buildjet-2vcpu-ubuntu-2204-arm" cache_id: arm64 runs-on: ${{ matrix.runs_on }} - permissions: - contents: read - packages: write steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/purge.yml b/.github/workflows/purge.yml index dd03f303b6..a6c9d3bc23 100644 --- a/.github/workflows/purge.yml +++ b/.github/workflows/purge.yml @@ -5,6 +5,10 @@ on: types: - closed +permissions: + contents: read + packages: write + jobs: purge-pr-untagged: name: Delete untagged images from ghcr.io From 5aaedf8d4b6f235108495e2f0b0bdfe1edd015e9 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 09:20:10 +0100 Subject: [PATCH 06/53] Distinct Elixir CI and PR Build --- .github/workflows/elixir.yml | 58 +------------------ .github/workflows/ghcr_build.yml | 57 ++++++++++++++++++ .../workflows/{purge.yml => ghcr_purge.yml} | 0 3 files changed, 59 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/ghcr_build.yml rename .github/workflows/{purge.yml => ghcr_purge.yml} (100%) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index d19b449713..2de0b19f1f 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -1,65 +1,11 @@ -name: Elixir CI & PR images +name: Elixir CI on: push: - branches: - - "master" - - "v*" - tags: - - "v*" pull_request: branches: [ "master" ] -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -permissions: - contents: read - packages: write - jobs: - build: - name: Build images (only if pull_request) - if: github.event_name == 'pull_request' - strategy: - fail-fast: false - matrix: - include: - - platform: "linux/amd64" - runs_on: "ubuntu-latest" - cache_id: amd64 - - platform: "linux/arm/v7" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm - - platform: "linux/arm64" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm64 - runs-on: ${{ matrix.runs_on }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - labels: | - org.opencontainers.image.version=${{ github.ref || github.ref_name }} - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - lint: name: Lint (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}) runs-on: ubuntu-20.04 @@ -241,4 +187,4 @@ jobs: - name: Check Coverage if: github.ref == 'refs/heads/master' && matrix.report_coverage run: mix coveralls.github - continue-on-error: true + continue-on-error: true \ No newline at end of file diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml new file mode 100644 index 0000000000..bf3bebf617 --- /dev/null +++ b/.github/workflows/ghcr_build.yml @@ -0,0 +1,57 @@ +name: Build PR images + +on: + push: + branches: + - "master" + pull_request: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +permissions: + contents: read + packages: write + +jobs: + build: + name: Build GHCR images + strategy: + fail-fast: false + matrix: + include: + - platform: "linux/amd64" + runs_on: "ubuntu-latest" + cache_id: amd64 + - platform: "linux/arm/v7" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm + - platform: "linux/arm64" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm64 + runs-on: ${{ matrix.runs_on }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{github.actor}} + password: ${{secrets.GITHUB_TOKEN}} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + labels: | + org.opencontainers.image.version=${{ github.ref || github.ref_name }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/purge.yml b/.github/workflows/ghcr_purge.yml similarity index 100% rename from .github/workflows/purge.yml rename to .github/workflows/ghcr_purge.yml From 476caf5282a3dcdd4504fcfe6dd958c28f906641 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 09:20:49 +0100 Subject: [PATCH 07/53] Rename build --- .github/workflows/ghcr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index bf3bebf617..8812ee8be4 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -1,4 +1,4 @@ -name: Build PR images +name: Build GHCR images on: push: @@ -17,7 +17,7 @@ permissions: jobs: build: - name: Build GHCR images + name: Build images strategy: fail-fast: false matrix: From 3a9fb0160f4aaa4f9e83d08cc2998ee75b872720 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 09:25:14 +0100 Subject: [PATCH 08/53] Fix type --- .github/workflows/elixir.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 2de0b19f1f..0eb62d86c2 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -187,4 +187,4 @@ jobs: - name: Check Coverage if: github.ref == 'refs/heads/master' && matrix.report_coverage run: mix coveralls.github - continue-on-error: true \ No newline at end of file + continue-on-error: true From 54a0e1058d4dcc62d14a3638f6e3152b735b5e98 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 10:13:37 +0100 Subject: [PATCH 09/53] Add workflow_dispatch --- .github/workflows/ghcr_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 8812ee8be4..36cf5d79fc 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -1,6 +1,7 @@ name: Build GHCR images on: + workflow_dispatch: push: branches: - "master" From 598d6394609f22f406ef80cd7a343374cc4b2317 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 10:16:06 +0100 Subject: [PATCH 10/53] Add timeout to prevent stuck jobs --- .github/workflows/ghcr_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 36cf5d79fc..9183a5b3f7 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -33,6 +33,7 @@ jobs: runs_on: "buildjet-2vcpu-ubuntu-2204-arm" cache_id: arm64 runs-on: ${{ matrix.runs_on }} + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 From 1e071abcf71af269006b1f301504cb6bc0150f5f Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 14:30:55 +0100 Subject: [PATCH 11/53] Add actions for buildx and merge --- .github/actions/build/action.yaml | 68 +++++++++++++++++++++++++++++++ .github/actions/merge/action.yml | 12 ++++++ .github/workflows/buildx.yml | 58 ++++---------------------- .github/workflows/ghcr_build.yml | 59 +++++++++++++++++---------- 4 files changed, 127 insertions(+), 70 deletions(-) create mode 100644 .github/actions/build/action.yaml create mode 100644 .github/actions/merge/action.yml diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml new file mode 100644 index 0000000000..ef6ee18b23 --- /dev/null +++ b/.github/actions/build/action.yaml @@ -0,0 +1,68 @@ +name: 'Build' +description: 'Build images' +inputs: + docker_user: + description: 'Docker user' + required: false + default: teslamate + docker_password: + description: 'Docker password' + required: true + repository_owner: + description: 'Repository owner' + required: true + 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 + uses: docker/login-action@v3.0.0 + with: + username: ${{ inputs.docker_user }} + password: ${{ inputs.docker_password }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ inputs.repository_owner }} + password: ${{ inputs.github_token }} + - name: Build and push by digest + id: build + uses: docker/build-push-action@v5.0.0 + 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 + shell: bash + run: | + mkdir -p /tmp/teslamate/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/teslamate/digests/${digest#sha256:}" + echo ${{ env.DOCKER_METADATA_OUTPUT_VERSION }} > /tmp/teslamate/version + - name: Upload digest + uses: actions/upload-artifact@v3 + with: + name: digests + path: /tmp/teslamate/* + if-no-files-found: error + retention-days: 1 \ No newline at end of file diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml new file mode 100644 index 0000000000..41f1d88f31 --- /dev/null +++ b/.github/actions/merge/action.yml @@ -0,0 +1,12 @@ +name: 'Merge' +description: 'Merge images' +runs: + using: "composite" + steps: + - name: Download digests + uses: actions/download-artifact@v3 + with: + name: digests + path: /tmp/teslamate + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 \ No newline at end of file diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 8e6999c77a..f49d0fe29c 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -34,61 +34,21 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - uses: docker/login-action@v3.0.0 - with: - username: teslamate - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Login to GitHub Container Registry - uses: docker/login-action@v3.0.0 + uses: actions/checkout@v4 + - name: Buildx + uses: ./.github/actions/build with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push by digest - id: build - uses: docker/build-push-action@v5.0.0 - 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 }} + github_token: ${{ secrets.GITHUB_TOKEN }} teslamate_merge: runs-on: ubuntu-latest needs: - teslamate_build 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 + - uses: ./.github/actions/merge + - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -105,7 +65,7 @@ jobs: username: teslamate password: ${{ secrets.DOCKER_PASSWORD }} - name: Create manifest list and push - working-directory: /tmp/digests + working-directory: /tmp/teslamate/digests run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 9183a5b3f7..dda663b4a8 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -9,15 +9,14 @@ on: branches: [ "master" ] env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + REGISTRY_IMAGE: ghcr.io/teslamate-org/teslamate permissions: contents: read packages: write jobs: - build: + teslamate_build: name: Build images strategy: fail-fast: false @@ -36,24 +35,42 @@ jobs: timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v4 - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 + uses: actions/checkout@v4 + - name: Buildx + uses: ./.github/actions/build with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + docker_password: ${{ secrets.DOCKER_PASSWORD }} + repository_owner: ${{ github.repository_owner }} + github_token: ${{ secrets.GITHUB_TOKEN }} labels: | - org.opencontainers.image.version=${{ github.ref || github.ref_name }} - - name: Build and push Docker image - uses: docker/build-push-action@v4 + org.opencontainers.image.version=${{ github.ref || github.ref_name }} + + teslamate_merge: + name: Merge GHCR images + runs-on: ubuntu-latest + needs: + - teslamate_build + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Merge + id: merge + uses: ./.github/actions/merge + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.0.0 with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create manifest list and push + working-directory: /tmp/teslamate/digests + run: | + docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) \ No newline at end of file From ad6d00cd133642916ca5db470b72e1b9c1d559d0 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 14:36:10 +0100 Subject: [PATCH 12/53] fix username ? --- .github/actions/build/action.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index ef6ee18b23..d0b08815e9 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -1,10 +1,6 @@ name: 'Build' description: 'Build images' inputs: - docker_user: - description: 'Docker user' - required: false - default: teslamate docker_password: description: 'Docker password' required: true @@ -33,7 +29,7 @@ runs: - name: Login to Docker Hub uses: docker/login-action@v3.0.0 with: - username: ${{ inputs.docker_user }} + username: teslamate password: ${{ inputs.docker_password }} - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 From c028a3edec40e181bf41e508790d807cc6572504 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 15 Nov 2023 16:48:01 +0100 Subject: [PATCH 13/53] Add grafana images from PR --- .github/actions/grafana/action.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/buildx.yml | 28 +++++----------------- .github/workflows/ghcr_build.yml | 23 +++++++++++++++++-- 3 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 .github/actions/grafana/action.yml diff --git a/.github/actions/grafana/action.yml b/.github/actions/grafana/action.yml new file mode 100644 index 0000000000..ada4441b20 --- /dev/null +++ b/.github/actions/grafana/action.yml @@ -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: 'myteslamate/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/build-push-action@v5.0.0 + 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 diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index f49d0fe29c..fdec63e128 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -31,6 +31,7 @@ jobs: cache_id: arm64 runs-on: ${{ matrix.runs_on }} + timeout-minutes: 10 steps: - name: Checkout @@ -75,34 +76,17 @@ jobs: 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/login-action@v3.0.0 - with: - username: teslamate - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push - uses: docker/build-push-action@v5.0.0 - 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 + + \ No newline at end of file diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index dda663b4a8..4be1e98df1 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -30,7 +30,7 @@ jobs: cache_id: arm - platform: "linux/arm64" runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm64 + cache_id: arm64 runs-on: ${{ matrix.runs_on }} timeout-minutes: 10 steps: @@ -73,4 +73,23 @@ jobs: $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) \ No newline at end of file + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) + + grafana: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/actions/grafana + with: + image: ghcr.io/teslamate/teslamate/grafana + labels: | + org.opencontainers.image.version=${{ github.ref || github.ref_name }} \ No newline at end of file From 4985f7811e9c72752eaa7311e98dc40d0692bcea Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 09:21:25 +0100 Subject: [PATCH 14/53] fix typo --- .github/actions/grafana/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/grafana/action.yml b/.github/actions/grafana/action.yml index ada4441b20..a732b5422b 100644 --- a/.github/actions/grafana/action.yml +++ b/.github/actions/grafana/action.yml @@ -11,7 +11,7 @@ inputs: image: description: 'Image target' required: true - default: 'myteslamate/grafana' + default: 'teslamate/grafana' runs: using: "composite" steps: From e3d72228664ced9ab921928d619cad5d24faf6a5 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 12:40:13 +0100 Subject: [PATCH 15/53] Finih merge action refactoring --- .github/actions/build/action.yaml | 7 +++---- .github/actions/merge/action.yml | 31 +++++++++++++++++++++++++++++-- .github/workflows/buildx.yml | 31 +++++++++++-------------------- .github/workflows/ghcr_build.yml | 19 +++++-------------- 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index d0b08815e9..8b5d209608 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -51,14 +51,13 @@ runs: - name: Export digest shell: bash run: | - mkdir -p /tmp/teslamate/digests + mkdir -p /tmp/digests digest="${{ steps.build.outputs.digest }}" - touch "/tmp/teslamate/digests/${digest#sha256:}" - echo ${{ env.DOCKER_METADATA_OUTPUT_VERSION }} > /tmp/teslamate/version + touch "/tmp/digests/${digest#sha256:}" - name: Upload digest uses: actions/upload-artifact@v3 with: name: digests - path: /tmp/teslamate/* + path: /tmp/digests/* if-no-files-found: error retention-days: 1 \ No newline at end of file diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml index 41f1d88f31..8652387802 100644 --- a/.github/actions/merge/action.yml +++ b/.github/actions/merge/action.yml @@ -1,5 +1,14 @@ name: 'Merge' description: 'Merge images' +inputs: + tags: + description: 'Tags' + required: false + default: '' + image: + description: 'Image target' + required: true + runs: using: "composite" steps: @@ -7,6 +16,24 @@ runs: uses: actions/download-artifact@v3 with: name: digests - path: /tmp/teslamate + path: /tmp/digest - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 \ No newline at end of file + 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 }} diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index fdec63e128..f6c36f1c93 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -47,33 +47,24 @@ jobs: runs-on: ubuntu-latest needs: - teslamate_build - steps: + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3.0.0 + with: + username: teslamate + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: ./.github/actions/merge - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 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/login-action@v3.0.0 - with: - username: teslamate - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Create manifest list and push - working-directory: /tmp/teslamate/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 diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 4be1e98df1..dbb92c724f 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -54,26 +54,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - - name: Merge - id: merge - uses: ./.github/actions/merge - - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Create manifest list and push - working-directory: /tmp/teslamate/digests - run: | - docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(cat /tmp/teslamate/version) + - name: Merge + id: merge + uses: ./.github/actions/merge + with: + image: ${{ env.REGISTRY_IMAGE }} grafana: runs-on: ubuntu-latest From 20b84bba0af4f9cc606729679b2e5083b4f33b4a Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 12:54:04 +0100 Subject: [PATCH 16/53] Exclude PRs related to .github from auto-run --- .github/workflows/elixir.yml | 6 ++++++ .github/workflows/ghcr_build.yml | 7 +++++-- .github/workflows/ghcr_purge.yml | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 0eb62d86c2..2a405b8e22 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -2,8 +2,14 @@ name: Elixir CI on: push: + paths: + - '**/*' + - '!.github/**' # Important: Exclude PRs related to .github from auto-run pull_request: branches: [ "master" ] + paths: + - '**/*' + - '!.github/**' # Important: Exclude PRs related to .github from auto-run jobs: lint: diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index dbb92c724f..2f4b2585bd 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -2,11 +2,14 @@ name: Build GHCR images on: workflow_dispatch: - push: + push: branches: - - "master" + - "master" pull_request: branches: [ "master" ] + paths: + - '**/*' + - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: REGISTRY_IMAGE: ghcr.io/teslamate-org/teslamate diff --git a/.github/workflows/ghcr_purge.yml b/.github/workflows/ghcr_purge.yml index a6c9d3bc23..9fb84bfb43 100644 --- a/.github/workflows/ghcr_purge.yml +++ b/.github/workflows/ghcr_purge.yml @@ -2,6 +2,9 @@ name: Purge PR images on: pull_request_target: + paths: + - '**/*' + - '!.github/**' # Important: Exclude PRs related to .github from auto-run types: - closed From ead1e590a7b9bb817729ff0dcdd5ebe9a4ebb7bb Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 14:53:34 +0100 Subject: [PATCH 17/53] Don't try to auth on DockerHub when we can't --- .github/actions/build/action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 8b5d209608..f4676fa02a 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -27,6 +27,7 @@ runs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub + if: inputs.docker_password != '' uses: docker/login-action@v3.0.0 with: username: teslamate @@ -60,4 +61,4 @@ runs: name: digests path: /tmp/digests/* if-no-files-found: error - retention-days: 1 \ No newline at end of file + retention-days: 1 From 7df4bdb35a69ea5418dc1ec7a33e76c5020c56a4 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 14:54:59 +0100 Subject: [PATCH 18/53] tmp allow myself to execute --- .github/workflows/ghcr_build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 2f4b2585bd..d5989fda24 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -7,9 +7,9 @@ on: - "master" pull_request: branches: [ "master" ] - paths: - - '**/*' - - '!.github/**' # Important: Exclude PRs related to .github from auto-run +# paths: +# - '**/*' +# - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: REGISTRY_IMAGE: ghcr.io/teslamate-org/teslamate @@ -86,4 +86,4 @@ jobs: with: image: ghcr.io/teslamate/teslamate/grafana labels: | - org.opencontainers.image.version=${{ github.ref || github.ref_name }} \ No newline at end of file + org.opencontainers.image.version=${{ github.ref || github.ref_name }} From 3865d749c7b0215652e65c309216b57cc966e5a6 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:05:43 +0100 Subject: [PATCH 19/53] Update ghcr_build.yml to be able to write on packages from public fork --- .github/workflows/ghcr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index d5989fda24..2867589d80 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -5,7 +5,7 @@ on: push: branches: - "master" - pull_request: + pull_request_target: branches: [ "master" ] # paths: # - '**/*' From a6b242b604fde8a457db2f945908904c5d83029c Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:09:31 +0100 Subject: [PATCH 20/53] Revert ghcr_build.yml --- .github/workflows/ghcr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 2867589d80..d5989fda24 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -5,7 +5,7 @@ on: push: branches: - "master" - pull_request_target: + pull_request: branches: [ "master" ] # paths: # - '**/*' From 215bfcda3e5bbc8f1b567217f0a3603d0df2b386 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:29:57 +0100 Subject: [PATCH 21/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index d5989fda24..2867589d80 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -5,7 +5,7 @@ on: push: branches: - "master" - pull_request: + pull_request_target: branches: [ "master" ] # paths: # - '**/*' From d427dc3a5d19a8f14475ceebc499d9814e3d057b Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:40:24 +0100 Subject: [PATCH 22/53] Update to build on source repo --- .github/workflows/ghcr_build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 2867589d80..2b8db26d04 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -12,7 +12,8 @@ on: # - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: - REGISTRY_IMAGE: ghcr.io/teslamate-org/teslamate + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} + permissions: contents: read From 6d735cc68f53f4bd0532da979205acfb90b1d411 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:45:04 +0100 Subject: [PATCH 23/53] Update ghcr_build.yml to test --- .github/workflows/ghcr_build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 2b8db26d04..15a30e5d98 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -76,6 +76,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Export digest + shell: bash + run: | + env + - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 with: From e709cda62486a46101846e12ba30b583dc6ea3a5 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:47:27 +0100 Subject: [PATCH 24/53] Use correct repo with REGISTRY_IMAGE --- .github/workflows/ghcr_build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 15a30e5d98..0bd2dbbe27 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -12,8 +12,7 @@ on: # - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: - REGISTRY_IMAGE: ghcr.io/${{ github.repository }} - + REGISTRY_IMAGE: ${{ env.REGISTRY_IMAGE }} permissions: contents: read From 4c8fc7a0bdb065791a26bf28f20ab599ec0faaf7 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:48:24 +0100 Subject: [PATCH 25/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 0bd2dbbe27..9512ec7a42 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -11,8 +11,8 @@ on: # - '**/*' # - '!.github/**' # Important: Exclude PRs related to .github from auto-run -env: - REGISTRY_IMAGE: ${{ env.REGISTRY_IMAGE }} +#env: +# REGISTRY_IMAGE: ${{ env.REGISTRY_IMAGE }} permissions: contents: read From 847d977780bda77ec0e6d77cd9dcfc5c161c306f Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:50:52 +0100 Subject: [PATCH 26/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 9512ec7a42..d8de8546cf 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -11,8 +11,8 @@ on: # - '**/*' # - '!.github/**' # Important: Exclude PRs related to .github from auto-run -#env: -# REGISTRY_IMAGE: ${{ env.REGISTRY_IMAGE }} +env: + REGISTRY_IMAGE: ghcr.io/${{ env.GITHUB_REPOSITORY }} permissions: contents: read From a963e45d893d1d42401ca0da2eb45ee64939f753 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 15:57:07 +0100 Subject: [PATCH 27/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index d8de8546cf..708184a73c 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -12,7 +12,7 @@ on: # - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: - REGISTRY_IMAGE: ghcr.io/${{ env.GITHUB_REPOSITORY }} + REGISTRY_IMAGE: ghcr.io/${{ github.actor }}/teslamate permissions: contents: read From b8eae505f9b87bea8dab8a69cec911d174b3de7e Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:34:47 +0100 Subject: [PATCH 28/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 708184a73c..288468f95f 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -79,6 +79,13 @@ jobs: shell: bash run: | env + echo "a" + echo ${{ github.repository_owner }} + echo "b" + echo ${{ github.actor }} + echo "c" + echo ${{ env.GITHUB_REPOSITORY }} + - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 From 42fed5c003fac15e79f869e1d2ed60b75e488d66 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:39:15 +0100 Subject: [PATCH 29/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 288468f95f..d09e7c876d 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -12,7 +12,7 @@ on: # - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: - REGISTRY_IMAGE: ghcr.io/${{ github.actor }}/teslamate + REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/teslamate permissions: contents: read @@ -85,8 +85,7 @@ jobs: echo ${{ github.actor }} echo "c" echo ${{ env.GITHUB_REPOSITORY }} - - + - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 with: @@ -96,6 +95,6 @@ jobs: - uses: ./.github/actions/grafana with: - image: ghcr.io/teslamate/teslamate/grafana + image: ghcr.io/${{ github.repository_owner }}/teslamate/grafana labels: | org.opencontainers.image.version=${{ github.ref || github.ref_name }} From 7a2cb1d5d022dcd2a22dcf0da67e72192ecfb679 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:42:53 +0100 Subject: [PATCH 30/53] Use dynamic variables to work in all repos --- .github/workflows/ghcr_build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index d09e7c876d..87e819e2f6 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -12,7 +12,7 @@ on: # - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: - REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/teslamate + REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.repository }} permissions: contents: read @@ -28,12 +28,12 @@ jobs: - platform: "linux/amd64" runs_on: "ubuntu-latest" cache_id: amd64 - - platform: "linux/arm/v7" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm - - platform: "linux/arm64" - runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm64 +# - platform: "linux/arm/v7" +# runs_on: "buildjet-2vcpu-ubuntu-2204-arm" +# cache_id: arm +# - platform: "linux/arm64" +# runs_on: "buildjet-2vcpu-ubuntu-2204-arm" +# cache_id: arm64 runs-on: ${{ matrix.runs_on }} timeout-minutes: 10 steps: @@ -95,6 +95,6 @@ jobs: - uses: ./.github/actions/grafana with: - image: ghcr.io/${{ github.repository_owner }}/teslamate/grafana + image: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/grafana labels: | org.opencontainers.image.version=${{ github.ref || github.ref_name }} From 3d1d5c16e6a16d5ec9433101c31ea7471db0e9f7 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:44:01 +0100 Subject: [PATCH 31/53] Purge in source repo --- .github/workflows/ghcr_purge.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ghcr_purge.yml b/.github/workflows/ghcr_purge.yml index 9fb84bfb43..a6c9d3bc23 100644 --- a/.github/workflows/ghcr_purge.yml +++ b/.github/workflows/ghcr_purge.yml @@ -2,9 +2,6 @@ name: Purge PR images on: pull_request_target: - paths: - - '**/*' - - '!.github/**' # Important: Exclude PRs related to .github from auto-run types: - closed From 20e4f749bb85730b75e848b4f993b685d56be196 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:45:12 +0100 Subject: [PATCH 32/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 87e819e2f6..9bca6b8820 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -7,9 +7,6 @@ on: - "master" pull_request_target: branches: [ "master" ] -# paths: -# - '**/*' -# - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.repository }} From d8ef4cd8c463bf1c18b2be2b2f0762f07b48ea2a Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:46:02 +0100 Subject: [PATCH 33/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 9bca6b8820..e427a9e388 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -72,17 +72,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Export digest - shell: bash - run: | - env - echo "a" - echo ${{ github.repository_owner }} - echo "b" - echo ${{ github.actor }} - echo "c" - echo ${{ env.GITHUB_REPOSITORY }} - - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 with: From e6267d9c2ab63b1cfe6edfaf438e9f7153fb8fd2 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 16:58:31 +0100 Subject: [PATCH 34/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index e427a9e388..77832ba3c1 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -81,6 +81,6 @@ jobs: - uses: ./.github/actions/grafana with: - image: ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/grafana + image: ${{ env.REGISTRY_IMAGE }}/grafana labels: | org.opencontainers.image.version=${{ github.ref || github.ref_name }} From f1a80763b03a91a85b21239b5afbbe55b4e7c511 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:01:05 +0100 Subject: [PATCH 35/53] Update action.yaml --- .github/actions/build/action.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index f4676fa02a..d9efc99413 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -14,6 +14,14 @@ inputs: description: 'Labels added on metadata' required: false default: '' + org: + description: 'Organisation name' + required: true + default: 'teslamate-org' + repo: + description: 'Repo name' + required: true + default: 'teslamate' runs: using: "composite" steps: @@ -46,8 +54,8 @@ runs: 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 + cache-from: type=registry,ref=ghcr.io/${{ inputs.org }}/${{ inputs.repo }}:buildcache-${{ matrix.cache_id }} + cache-to: type=registry,ref=ghcr.io/${{ inputs.org }}/${{ inputs.repo }}: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 From 8e313724b728b5e72e8e3a3a92894ed10c168ebf Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:02:39 +0100 Subject: [PATCH 36/53] Update ghcr_build.yml --- .github/workflows/ghcr_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 77832ba3c1..0ce684fb20 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -41,6 +41,7 @@ jobs: with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} + repository_name: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} labels: | org.opencontainers.image.version=${{ github.ref || github.ref_name }} From e51fd86bd676457ee236fbfd16354b8f112e3734 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:03:02 +0100 Subject: [PATCH 37/53] Update buildx.yml --- .github/workflows/buildx.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index f6c36f1c93..8b7cbf8c46 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -41,6 +41,7 @@ jobs: with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} + repository_name: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} teslamate_merge: @@ -80,4 +81,4 @@ jobs: type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - \ No newline at end of file + From 65f958235f29bf301387d4546e9a260396672148 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:03:50 +0100 Subject: [PATCH 38/53] Update action.yaml --- .github/actions/build/action.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index d9efc99413..4cb8cc79fd 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -7,6 +7,11 @@ inputs: repository_owner: description: 'Repository owner' required: true + default: 'teslamate-org' + repository_name: + description: 'Repo name' + required: true + default: 'teslamate' github_token: description: 'GitHub Token' required: true @@ -14,14 +19,6 @@ inputs: description: 'Labels added on metadata' required: false default: '' - org: - description: 'Organisation name' - required: true - default: 'teslamate-org' - repo: - description: 'Repo name' - required: true - default: 'teslamate' runs: using: "composite" steps: From c82e4167f341d63f2a4a6a9fc684be46b79c9bcf Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:06:19 +0100 Subject: [PATCH 39/53] Fix vars --- .github/actions/build/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 4cb8cc79fd..b2bf38bf85 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -51,8 +51,8 @@ runs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.docker_meta.outputs.tags }} - cache-from: type=registry,ref=ghcr.io/${{ inputs.org }}/${{ inputs.repo }}:buildcache-${{ matrix.cache_id }} - cache-to: type=registry,ref=ghcr.io/${{ inputs.org }}/${{ inputs.repo }}:buildcache-${{ matrix.cache_id }},mode=max + cache-from: type=registry,ref=ghcr.io/${{ inputs.repository_owner }}/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }} + cache-to: type=registry,ref=ghcr.io/${{ inputs.repository_owner }}/${{ inputs.repository_name }}: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 From 91421f543d9fe77e41bee89af1f40eac48e795cd Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:15:23 +0100 Subject: [PATCH 40/53] Trace digests --- .github/actions/build/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index b2bf38bf85..29b185a5c2 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -60,6 +60,7 @@ runs: 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: From 36ee0b637b7ab46b4644a0b4e7225d0cddf27cf5 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:26:22 +0100 Subject: [PATCH 41/53] Update action.yml --- .github/actions/merge/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml index 8652387802..e5f74e9496 100644 --- a/.github/actions/merge/action.yml +++ b/.github/actions/merge/action.yml @@ -17,6 +17,13 @@ runs: with: name: digests path: /tmp/digest + + - name: Test + shell: bash + run: | + ls -l /tmp/ + ls -l /tmp/digests/ + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From a9c886138f40b8c8f6c83d03f5dc12e176cf3ef4 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:28:28 +0100 Subject: [PATCH 42/53] Update action.yml --- .github/actions/merge/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml index e5f74e9496..bfa7f3a971 100644 --- a/.github/actions/merge/action.yml +++ b/.github/actions/merge/action.yml @@ -22,7 +22,7 @@ runs: shell: bash run: | ls -l /tmp/ - ls -l /tmp/digests/ + ls -l /tmp/digest/ - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 3746d9f72fad5c165851cbc9d4c91d5be115ad3d Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:34:52 +0100 Subject: [PATCH 43/53] Fix typo --- .github/actions/merge/action.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml index bfa7f3a971..2e480ee342 100644 --- a/.github/actions/merge/action.yml +++ b/.github/actions/merge/action.yml @@ -16,14 +16,8 @@ runs: uses: actions/download-artifact@v3 with: name: digests - path: /tmp/digest + path: /tmp/digests - - name: Test - shell: bash - run: | - ls -l /tmp/ - ls -l /tmp/digest/ - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From e771097cf7898b88518a9d913d7fe4e6024194cb Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:40:33 +0100 Subject: [PATCH 44/53] Fox repo name --- .github/workflows/ghcr_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 0ce684fb20..8061194927 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -9,7 +9,7 @@ on: branches: [ "master" ] env: - REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.repository }} + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} permissions: contents: read @@ -41,7 +41,7 @@ jobs: with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} - repository_name: ${{ github.repository }} + repository: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} labels: | org.opencontainers.image.version=${{ github.ref || github.ref_name }} From 4033fcf7ba03c529d525ed0913629472f4d91cb8 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:42:09 +0100 Subject: [PATCH 45/53] Update buildx.yml --- .github/workflows/buildx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 8b7cbf8c46..340dc79cf3 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -41,7 +41,7 @@ jobs: with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} - repository_name: ${{ github.repository }} + repository: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} teslamate_merge: From 107e5c67e9fe5f0a073328267b48836f7f52dd5b Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:43:20 +0100 Subject: [PATCH 46/53] Update action.yaml --- .github/actions/build/action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index 29b185a5c2..aa9974d687 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -8,8 +8,8 @@ inputs: description: 'Repository owner' required: true default: 'teslamate-org' - repository_name: - description: 'Repo name' + repository: + description: 'Repo owner and name (repo_owner/repo_name)' required: true default: 'teslamate' github_token: @@ -51,8 +51,8 @@ runs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.docker_meta.outputs.tags }} - cache-from: type=registry,ref=ghcr.io/${{ inputs.repository_owner }}/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }} - cache-to: type=registry,ref=ghcr.io/${{ inputs.repository_owner }}/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }},mode=max + cache-from: type=registry,ref=ghcr.io/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }} + cache-to: type=registry,ref=ghcr.io/${{ inputs.repository_name }}: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 From c45e127ad46e224030ba0c60b829f21f8d5fe12e Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:43:38 +0100 Subject: [PATCH 47/53] Fix repository name --- .github/actions/build/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index aa9974d687..fd3aba7f59 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -51,8 +51,8 @@ runs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.docker_meta.outputs.tags }} - cache-from: type=registry,ref=ghcr.io/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }} - cache-to: type=registry,ref=ghcr.io/${{ inputs.repository_name }}:buildcache-${{ matrix.cache_id }},mode=max + 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 From 8e7a14d99dc1ffeff1920210404afbed881072b3 Mon Sep 17 00:00:00 2001 From: jlestel Date: Thu, 16 Nov 2023 17:50:32 +0100 Subject: [PATCH 48/53] Run on any branch pushed --- .github/workflows/ghcr_build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 8061194927..d2385dd80e 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -2,9 +2,7 @@ name: Build GHCR images on: workflow_dispatch: - push: - branches: - - "master" + push: pull_request_target: branches: [ "master" ] From 1b3824effc082ea1e4d4e3c0fd2d5466535ed013 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 19:50:25 +0100 Subject: [PATCH 49/53] Exclude PRs related to .github from auto-run --- .github/workflows/ghcr_build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index d2385dd80e..01e70fd217 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -3,8 +3,14 @@ name: Build GHCR images on: workflow_dispatch: push: + paths: + - '**/*' + - '!.github/**' pull_request_target: branches: [ "master" ] + paths: + - '**/*' + - '!.github/**' # Important: Exclude PRs related to .github from auto-run env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} From c291627227fad0c7de0c8c9726598093ad0ecaa6 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 19:52:02 +0100 Subject: [PATCH 50/53] Add buildjet dependency --- .github/workflows/ghcr_build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index 01e70fd217..f4f99019d0 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -29,12 +29,12 @@ jobs: - platform: "linux/amd64" runs_on: "ubuntu-latest" cache_id: amd64 -# - platform: "linux/arm/v7" -# runs_on: "buildjet-2vcpu-ubuntu-2204-arm" -# cache_id: arm -# - platform: "linux/arm64" -# runs_on: "buildjet-2vcpu-ubuntu-2204-arm" -# cache_id: arm64 + - platform: "linux/arm/v7" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm + - platform: "linux/arm64" + runs_on: "buildjet-2vcpu-ubuntu-2204-arm" + cache_id: arm64 runs-on: ${{ matrix.runs_on }} timeout-minutes: 10 steps: From ce2944b0744087f4f6eb5d9666c25a53a5ceba9d Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 20:15:47 +0100 Subject: [PATCH 51/53] lint --- .github/workflows/buildx.yml | 8 +++----- .github/workflows/elixir.yml | 12 ++++++------ .github/workflows/ghcr_build.yml | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 340dc79cf3..8456692449 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -35,20 +35,20 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Buildx uses: ./.github/actions/build with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} - repository: ${{ github.repository }} + repository: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} teslamate_merge: runs-on: ubuntu-latest needs: - teslamate_build - steps: + steps: - name: Checkout uses: actions/checkout@v4 @@ -80,5 +80,3 @@ jobs: type=schedule,pattern=edge type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 2a405b8e22..9b000c6047 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -3,13 +3,13 @@ name: Elixir CI on: push: paths: - - '**/*' - - '!.github/**' # Important: Exclude PRs related to .github from auto-run + - "**/*" + - "!.github/**" # Important: Exclude PRs related to .github from auto-run pull_request: - branches: [ "master" ] + branches: ["master"] paths: - - '**/*' - - '!.github/**' # Important: Exclude PRs related to .github from auto-run + - "**/*" + - "!.github/**" # Important: Exclude PRs related to .github from auto-run jobs: lint: @@ -130,7 +130,7 @@ jobs: services: db: image: postgres:15 - ports: [ "5432:5432" ] + ports: ["5432:5432"] env: POSTGRES_PASSWORD: postgres options: >- diff --git a/.github/workflows/ghcr_build.yml b/.github/workflows/ghcr_build.yml index f4f99019d0..e93285a9c8 100644 --- a/.github/workflows/ghcr_build.yml +++ b/.github/workflows/ghcr_build.yml @@ -4,13 +4,13 @@ on: workflow_dispatch: push: paths: - - '**/*' - - '!.github/**' + - "**/*" + - "!.github/**" pull_request_target: - branches: [ "master" ] + branches: ["master"] paths: - - '**/*' - - '!.github/**' # Important: Exclude PRs related to .github from auto-run + - "**/*" + - "!.github/**" # Important: Exclude PRs related to .github from auto-run env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} @@ -34,21 +34,21 @@ jobs: cache_id: arm - platform: "linux/arm64" runs_on: "buildjet-2vcpu-ubuntu-2204-arm" - cache_id: arm64 + cache_id: arm64 runs-on: ${{ matrix.runs_on }} timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Buildx uses: ./.github/actions/build with: docker_password: ${{ secrets.DOCKER_PASSWORD }} repository_owner: ${{ github.repository_owner }} - repository: ${{ github.repository }} + repository: ${{ github.repository }} github_token: ${{ secrets.GITHUB_TOKEN }} labels: | - org.opencontainers.image.version=${{ github.ref || github.ref_name }} + org.opencontainers.image.version=${{ github.ref || github.ref_name }} teslamate_merge: name: Merge GHCR images @@ -58,7 +58,7 @@ jobs: timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Login to GitHub Container Registry uses: docker/login-action@v3.0.0 with: From 0a832d84917b0f24e3792e8af9c1cb86c6195957 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Nov 2023 20:16:51 +0100 Subject: [PATCH 52/53] lint actions --- .github/actions/build/action.yaml | 112 ++++++++++++++--------------- .github/actions/grafana/action.yml | 14 ++-- .github/actions/merge/action.yml | 14 ++-- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml index fd3aba7f59..a14750fcaf 100644 --- a/.github/actions/build/action.yaml +++ b/.github/actions/build/action.yaml @@ -1,70 +1,70 @@ -name: 'Build' -description: 'Build images' +name: "Build" +description: "Build images" inputs: docker_password: - description: 'Docker password' + description: "Docker password" required: true repository_owner: - description: 'Repository owner' + description: "Repository owner" required: true - default: 'teslamate-org' + default: "teslamate-org" repository: - description: 'Repo owner and name (repo_owner/repo_name)' + description: "Repo owner and name (repo_owner/repo_name)" required: true - default: 'teslamate' + default: "teslamate" github_token: - description: 'GitHub Token' + description: "GitHub Token" required: true labels: - description: 'Labels added on metadata' + description: "Labels added on metadata" required: false - default: '' + 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/login-action@v3.0.0 - with: - username: teslamate - password: ${{ inputs.docker_password }} - - name: Login to GitHub Container Registry - uses: docker/login-action@v3.0.0 - with: - registry: ghcr.io - username: ${{ inputs.repository_owner }} - password: ${{ inputs.github_token }} - - name: Build and push by digest - id: build - uses: docker/build-push-action@v5.0.0 - 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 + - 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/login-action@v3.0.0 + with: + username: teslamate + password: ${{ inputs.docker_password }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ inputs.repository_owner }} + password: ${{ inputs.github_token }} + - name: Build and push by digest + id: build + uses: docker/build-push-action@v5.0.0 + 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 diff --git a/.github/actions/grafana/action.yml b/.github/actions/grafana/action.yml index a732b5422b..151503c1e5 100644 --- a/.github/actions/grafana/action.yml +++ b/.github/actions/grafana/action.yml @@ -1,17 +1,17 @@ -name: 'Grafana' -description: 'Grafana images' +name: "Grafana" +description: "Grafana images" inputs: tags: - description: 'Tags' + description: "Tags" required: false - default: '' + default: "" labels: - description: 'Labels' + description: "Labels" required: true image: - description: 'Image target' + description: "Image target" required: true - default: 'teslamate/grafana' + default: "teslamate/grafana" runs: using: "composite" steps: diff --git a/.github/actions/merge/action.yml b/.github/actions/merge/action.yml index 2e480ee342..aa2c00e867 100644 --- a/.github/actions/merge/action.yml +++ b/.github/actions/merge/action.yml @@ -1,12 +1,12 @@ -name: 'Merge' -description: 'Merge images' +name: "Merge" +description: "Merge images" inputs: tags: - description: 'Tags' + description: "Tags" required: false - default: '' + default: "" image: - description: 'Image target' + description: "Image target" required: true runs: @@ -30,11 +30,11 @@ runs: - name: Create manifest list and push working-directory: /tmp/digests - shell: bash + 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 + shell: bash run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} From c34b8aac63eb8dde8fe7809562e2f13e64c2c70a Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 17 Nov 2023 01:16:47 +0100 Subject: [PATCH 53/53] fix: links in dashboards --- grafana/dashboards/charges.json | 6 +++--- grafana/dashboards/locations.json | 2 +- grafana/dashboards/trip.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grafana/dashboards/charges.json b/grafana/dashboards/charges.json index eacb87b855..d0529bd622 100644 --- a/grafana/dashboards/charges.json +++ b/grafana/dashboards/charges.json @@ -106,7 +106,7 @@ { "targetBlank": false, "title": "View charge details", - "url": "d/BHhxFeZRz?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}&var-car_id=${__data.fields.car_id.numeric}&var-charging_process_id=${__data.fields.id.numeric}" + "url": "d/BHhxFeZRz?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}&var-car_id=${__data.fields.car_id.numeric}&var-charging_process_id=${__data.fields.id.numeric:raw}" } ] }, @@ -302,7 +302,7 @@ { "targetBlank": false, "title": "Set Cost", - "url": "[[base_url:raw]]/charge-cost/${__data.fields.id.numeric}" + "url": "[[base_url:raw]]/charge-cost/${__data.fields.id.numeric:raw}" } ] }, @@ -389,7 +389,7 @@ { "targetBlank": true, "title": "Create or edit geo-fence", - "url": "[[base_url:raw]]/geo-fences/${__data.fields.path}" + "url": "[[base_url:raw]]/geo-fences/${__data.fields.path:raw}" } ] }, diff --git a/grafana/dashboards/locations.json b/grafana/dashboards/locations.json index 441042f312..2fc792bb36 100644 --- a/grafana/dashboards/locations.json +++ b/grafana/dashboards/locations.json @@ -969,7 +969,7 @@ { "targetBlank": true, "title": "", - "url": "[[base_url:raw]]/geo-fences/${__data.fields.id.numeric}/edit" + "url": "[[base_url:raw]]/geo-fences/${__data.fields.id.numeric:raw}/edit" } ] }, diff --git a/grafana/dashboards/trip.json b/grafana/dashboards/trip.json index 3f75aa1004..8d04db9791 100644 --- a/grafana/dashboards/trip.json +++ b/grafana/dashboards/trip.json @@ -1637,7 +1637,7 @@ { "targetBlank": false, "title": "View charge details", - "url": "d/BHhxFeZRz?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}&var-car_id=${__data.fields.car_id.numeric}&var-charging_process_id=${__data.fields.id.numeric}" + "url": "d/BHhxFeZRz?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}&var-car_id=${__data.fields.car_id.numeric}&var-charging_process_id=${__data.fields.id.numeric:raw}" } ] }, @@ -1782,7 +1782,7 @@ { "targetBlank": false, "title": "Set Cost", - "url": "[[base_url:raw]]/charge-cost/${__data.fields.id.numeric}" + "url": "[[base_url:raw]]/charge-cost/${__data.fields.id.numeric:raw}" } ] },