Skip to content

Commit

Permalink
🏗️ config(cd): Extract package/build-publish action.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Feb 3, 2025
1 parent c4e9cdf commit cfba48d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
45 changes: 45 additions & 0 deletions .github/actions/package/build-publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build-publish
description: >
Build and publish package to registry.
inputs:

context:
type: string
required: true

package:
type: string
required: true

runs:

using: composite

steps:

- name: Docker meta
id: meta-server
uses: docker/metadata-action@v5
with:
images: ${{ inputs.package }}
tags: |
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
type=schedule
type=edge
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.context }}
push: true
tags: ${{ steps.meta-server.outputs.tags }}
labels: ${{ steps.meta-server.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
26 changes: 3 additions & 23 deletions .github/workflows/ci:build:image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,18 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Docker meta
id: meta-server
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=sha,format=long
type=schedule
type=edge
- name: Log in to GitHub Packages registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v6
- name: Build and publish
uses: ./.github/actions/package/build-publish
with:
context: .
push: true
tags: ${{ steps.meta-server.outputs.tags }}
labels: ${{ steps.meta-server.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
package: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}


test:
Expand Down

0 comments on commit cfba48d

Please sign in to comment.