Skip to content

Commit

Permalink
Merge pull request #3 from ComposableFi/ci
Browse files Browse the repository at this point in the history
build and push docker
  • Loading branch information
rjonczy authored Apr 26, 2024
2 parents ae5b464 + 219db04 commit 3573f12
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build and Push Docker Image

on:
push:
branches:
- main
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out the code
uses: actions/checkout@v3

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker (tag)
id: meta-tag
if: github.ref_type == 'tag'
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
- name: Extract metadata (tags, labels) for Docker (branch)
id: meta-branch
if: github.ref_type == 'branch'
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-{{date 'YYYYMMDDHHmmss'}}-
- name: Build and Push Docker Image (tag)
if: github.ref_type == 'tag'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta-tag.outputs.tags }}
labels: ${{ steps.meta-tag.outputs.labels }}

- name: Build and Push Docker Image (branch)
if: github.ref_type == 'branch'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta-branch.outputs.tags }}
labels: ${{ steps.meta-branch.outputs.labels }}

0 comments on commit 3573f12

Please sign in to comment.