Skip to content

Merge pull request #3 from ComposableFi/ci #2

Merge pull request #3 from ComposableFi/ci

Merge pull request #3 from ComposableFi/ci #2

Workflow file for this run

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 }}