Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Build image using metadata-action
Browse files Browse the repository at this point in the history
This still builds the `:main` image via `ref=branch`, since that's in
use in places, but we now also build an `:edge` image that we can
migrate to, as is more conventional.
  • Loading branch information
pbrisbin committed Jun 15, 2023
1 parent c612120 commit 190a77c
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,36 @@ jobs:
runs-on: ubuntu-latest

steps:
- id: prep
run: |
image=restyled/sdk:$(echo "${{ github.sha }}" | head -c7)
if ${{ github.ref == 'refs/heads/main' }}; then
echo "::set-output name=tags::${image},restyled/sdk:main"
else
echo "::set-output name=tags::${image}"
fi
- id: meta
uses: docker/metadata-action@v4
with:
images: restyled/sdk
tags: |
type=edge
type=ref,event=branch
type=sha,prefix=
- id: buildx
uses: docker/setup-buildx-action@v1
- uses: docker/setup-buildx-action@v2

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-image-${{ github.sha }}
restore-keys: |
${{ runner.os }}-image-
- uses: docker/login-action@v1
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- uses: docker/build-push-action@v2
- uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
push: true
tags: ${{ steps.prep.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Avoids ever-growing cache hitting limits
- run: |
Expand Down

0 comments on commit 190a77c

Please sign in to comment.