Skip to content

chore(deps): bump ahmadnassri/action-semantic-release #423

chore(deps): bump ahmadnassri/action-semantic-release

chore(deps): bump ahmadnassri/action-semantic-release #423

Workflow file for this run

# ----------------------------------------------- #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #
on:
- push
- workflow_dispatch
name: push
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
permissions:
contents: write
packages: write
pull-requests: write
env:
NODE_ENV: test
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
image-name: ${{ steps.image.outputs.name }}
dockerfile: ${{ steps.dockerfile.outputs.exists }}
repository_is_template: ${{ steps.metadata.outputs.repository_is_template }}
repository_default_branch: ${{ steps.metadata.outputs.repository_default_branch }}
steps:
- uses: actions/[email protected]
- id: metadata
uses: ahmadnassri/[email protected]
- id: dockerfile
run: echo "exists=$([[ -f "${{ github.workspace }}/Dockerfile" ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"
- id: image
run: echo "name=$(basename "${GITHUB_REPOSITORY/node-//}")" >> "$GITHUB_OUTPUT"
commit-lint:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ahmadnassri/[email protected]
with:
config: .github/linters/.commit-lint.yml
mega-linter:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: oxsecurity/megalinter/flavors/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MEGALINTER_CONFIG: .github/linters/.mega-linter.yml
GITHUB_COMMENT_REPORTER: true
GITHUB_STATUS_REPORTER: true
- uses: actions/[email protected]
if: ${{ success() }} || ${{ failure() }}
with:
name: mega-linter-reports
path: |
megalinter-reports
mega-linter.log
npm-audit:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ahmadnassri/[email protected]
- uses: actions/[email protected]
with:
node-version: latest
- run: npm audit
env:
NPM_CONFIG_AUDIT_LEVEL: ${{ env.NPM_CONFIG_AUDIT_LEVEL || 'critical' }}
test-strategy:
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.parse.outputs.matrix }}
steps:
- uses: actions/[email protected]
- id: parse
run: echo "matrix=$(jq -c . < .github/test-matrix.json)" >> "$GITHUB_OUTPUT"
test:
needs:
- npm-audit
- test-strategy
timeout-minutes: 5
name: ${{ matrix.name || format('node v{0} @ {1}', matrix.node-version, matrix.os) || 'test-step' }}
strategy:
matrix: ${{ fromJSON(needs.test-strategy.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
with:
submodules: true
- uses: ahmadnassri/[email protected]
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
cache: npm
- uses: ahmadnassri/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
- run: npm ci
- run: npm run test:ci
release:
needs:
- test
- metadata
- commit-lint
- mega-linter
# only runs on main branch for non template repos
if: |
needs.metadata.outputs.repository_is_template == 'false' &&
needs.metadata.outputs.repository_default_branch == github.ref_name
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
published: ${{ steps.release.outputs.published }}
version: ${{ steps.release.outputs.release-version }}
version-major: ${{ steps.release.outputs.release-version-major }}
version-minor: ${{ steps.release.outputs.release-version-minor }}
steps:
- uses: actions/[email protected]
with:
submodules: true
- uses: actions/[email protected]
with:
cache: npm
- run: npm ci
- id: release
uses: ahmadnassri/[email protected]
with:
config: ${{ github.workspace }}/.semantic.json
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mirror:
needs: release
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
packages: write
if: ${{ needs.release.outputs.published == 'true' }}
steps:
- uses: actions/[email protected]
with:
submodules: true
- uses: actions/[email protected]
with:
registry-url: https://npm.pkg.github.com
node-version: latest
- name: publish to github registry
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
jq '.name = "@'"${GITHUB_REPOSITORY/node-/}"'"' package.json > /tmp/package.json; mv /tmp/package.json .
npm version --no-git-tag-version "v${{ needs.release.outputs.version }}"
npm publish
publish-strategy:
needs:
- metadata
timeout-minutes: 5
# only runs on main branch for non template repos
if: |
needs.metadata.outputs.repository_is_template == 'false' &&
needs.metadata.outputs.repository_default_branch == github.ref_name
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.parse.outputs.matrix }}
steps:
- uses: actions/[email protected]
- id: parse
run: echo "matrix=$(jq -c . < .github/publish-matrix.json)" >> "$GITHUB_OUTPUT"
publish-docker:
needs:
- release
- metadata
- publish-strategy
timeout-minutes: 5
if: |
needs.release.outputs.published == 'true' &&
needs.metadata.outputs.dockerfile == 'true'
name: ${{ format('publish to {0}', matrix.registry) || 'publish-step' }}
strategy:
matrix: ${{ fromJSON(needs.publish-strategy.outputs.matrix) }}
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/[email protected]
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
# login to docker hub
- uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
# login to github container registry
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
run: |
echo "name=${{ github.repository_owner }}/$(basename "${GITHUB_REPOSITORY/node-//}")" >> "$GITHUB_OUTPUT"
# publish
- uses: docker/build-push-action@v4
with:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:latest
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.version-major }}
${{ matrix.registry }}/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.version }}
labels: |
org.opencontainers.image.title=${{ needs.metadata.outputs.image-name }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ needs.release.outputs.version }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
template-sync:
timeout-minutes: 5
needs:
- metadata
- test
- commit-lint
- mega-linter
# only runs on main branch for template repos
if: |
needs.metadata.outputs.repository_is_template == 'true' &&
needs.metadata.outputs.repository_default_branch == github.ref_name
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: ahmadnassri/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}