Docker Build #192
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Build | |
concurrency: docker | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- Dockerfile | |
- scripts/entrypoint.sh | |
workflow_run: | |
workflows: ["CI"] | |
branches: [develop] | |
types: | |
- completed | |
workflow_dispatch: | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: "Get Previous tag" | |
id: previoustag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
with: | |
semver_only: true | |
initial_version: v0.0.0 | |
with_initial_version: true | |
- name: Get current date | |
id: getbuilddate | |
run: | | |
echo "date=$(date -u)" >> $GITHUB_OUTPUT | |
echo "isodate=$(date -u '+%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT | |
echo "tagdate=$(date -u '+%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
echo "timestamp=$(date -u '+%s')" >> $GITHUB_OUTPUT | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/sweetrpg/catalog-api | |
tags: | | |
type=raw,value=latest | |
type=raw,value=${{ steps.previoustag.outputs.tag }} | |
type=raw,value=${{ steps.getbuilddate.outputs.tagdate }} | |
type=ref,event=branch | |
type=ref,event=tag | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
# context: . | |
push: true | |
no-cache: true | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
BUILD_NUMBER=${{ github.run_number }} | |
BUILD_JOB=${{ github.job }} | |
BUILD_SHA=${{ github.sha }} | |
BUILD_DATE=${{ steps.getbuilddate.outputs.isodate }} | |
BUILD_VERSION=${{ steps.previoustag.outputs.tag }} | |
# tags: registry.sweetrpg.com/sweetrpg-catalog-api:latest | |
# - name: Scan image | |
# uses: sysdiglabs/scan-action@v1 | |
# with: | |
# image-tag: registry.sweetrpg.com/sweetrpg-catalog-api:latest | |
# sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }} | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ vars.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} | |
with: | |
environment: ${{ vars.SENTRY_ENV }} |