Skip to content

Commit

Permalink
adding Dockerfile build step.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Nov 15, 2023
1 parent 2ed8962 commit 7bb8046
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: CI
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# This workflow is triggered on pushes & pull requests
on:
pull_request:
branches:
- main
push:
branches: [ main ]
release:
types: [published]
jobs:

test:
name: Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -36,3 +42,49 @@ jobs:
flags: unittests
fail_ci_if_error: true
verbose: true
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
# only latest if push has a tag and we're building the "main" flavor
latest=${{ github.event_name == 'release' && github.ref_type == 'tag' }}
tags: |
# if this is a tag'd build, prefix it with the flavor (eg. main-v1.2.3 and sandbox-v1.2.3)
type=ref,event=tag
# if this is a main branch build, just tag it with the flavor (eg. main and sandbox)
type=raw,value=${{ github.ref_name }},enable=${{ github.ref_name == 'main' }}
# if this is a (non main) branch build, tag it with the flavor and branch name (eg. main-branch and sandbox-branch)
type=ref,event=branch,enable=${{ github.ref_name != 'main' }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 7bb8046

Please sign in to comment.