Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
add build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
liisaratsep committed Jun 29, 2022
1 parent 89decc0 commit 6004031
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.git/
.gitignore
/data
/data
.github
85 changes: 85 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Docker

on:
push:
tags: [ 'v*.*.*' ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository (with submodules)
uses: actions/checkout@v2
with:
submodules: recursive

- name: Extract semver
id: get_version
uses: battila7/get-version-action@v2

# Lowercase image name, as mixed case is not allowed while caching
- name: lowercase IMAGE_NAME
run: |
echo "IMAGE_NAME_LOWER=${IMAGE_NAME,,}" >>${GITHUB_ENV}
env:
IMAGE_NAME: '${{ env.IMAGE_NAME }}'

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
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@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
flavor: |
latest=${{ !github.event.release.prerelease }}
tags: |
type=semver,pattern={{version}}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}

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

# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:latest
cache-to: type=inline
build-args: |
API_VERSION=${{steps.get_version.outputs.version-without-v}}
- name: Generate SBOM
uses: anchore/[email protected]
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}:${{steps.get_version.outputs.version-without-v}}
github-token: ${{ secrets.GITHUB_TOKEN }}
format: cyclonedx-json

0 comments on commit 6004031

Please sign in to comment.