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