Skip to content

Merge branch 'dev' of https://github.com/Disane87/docudigger into dev #65

Merge branch 'dev' of https://github.com/Disane87/docudigger into dev

Merge branch 'dev' of https://github.com/Disane87/docudigger into dev #65

name: Semantic release
on:
workflow_dispatch:
push:
paths:
- 'src/**'
- 'dockerfile'
- '.releaserc'
branches:
- 'main'
- 'dev'
env:
GH_TOKEN: ${{ secrets.AUTH_GH }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NEW_RELEASE_PUBLISHED: false
jobs:
build:
runs-on: ubuntu-latest
outputs:
NEW_RELEASE_PUBLISHED: ${{ steps.semantic-release.outputs.new_release_published }}
NEXT_VERSION: ${{ steps.semantic-release.outputs.version }}
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- id: semantic-release
run: npm run semantic-release:ci
docker:
needs: build
runs-on: ubuntu-latest
if: needs.build.outputs.NEW_RELEASE_PUBLISHED
steps:
- env:
NEW_RELEASE_PUBLISHED: ${{ needs.build.outputs.NEW_RELEASE_PUBLISHED }}
NEXT_VERSION: ${{ needs.build.outputs.NEXT_VERSION }}
run: echo "Creating docker release for version $NEXT_VERSION"
- name: Checkout repository
uses: actions/checkout@v3
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
with:
cosign-release: 'v1.13.1'
- name: Setup Docker buildx
uses: docker/setup-buildx-action@6d5347c4025fdf2bb05167a2519cac535a14a408
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@1f401f745bf57e30b3a2800ad308a87d2ebdf14b
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GH_TOKEN }}
- name: Echo Version
run: |
echo "Docker: $NEXT_VERSION"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=latest,enable={{ is_default_branch }}
type=raw,value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{version}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{major}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=ref,event=branch
#type=sha
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@fdf7f43ecf7c1a5c7afe936410233728a8c2d9c2
with:
context: .
build-args: |
DOCUDIGGER_VERSION=${{ needs.build.outputs.NEXT_VERSION }}
platforms: linux/amd64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max