Skip to content

Commit

Permalink
Finih merge action refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien committed Nov 16, 2023
1 parent 4985f78 commit e3d7222
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
7 changes: 3 additions & 4 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 29 additions & 2 deletions .github/actions/merge/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
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/teslamate
path: /tmp/digest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
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 }}
31 changes: 11 additions & 20 deletions .github/workflows/buildx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
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
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/ghcr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand Down

0 comments on commit e3d7222

Please sign in to comment.