Skip to content

build: minor workflow fixes for the semantic-release job #3

build: minor workflow fixes for the semantic-release job

build: minor workflow fixes for the semantic-release job #3

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Timings CI - release
on:
push:
workflow_dispatch:
inputs:
force-docker:
description: 'Force publish docker image'
default: false
type: boolean
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20.12.x, 21.x, 22.x]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install node modules and run tests
run: |
npm ci --ignore-scripts
npm test
release:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' && needs.test.result == 'success'
outputs:
release-outputs: ${{ steps.release.outputs }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21
cache: 'npm'
- name: Install node modules and run tests
run: |
npm ci --ignore-scripts
- name: Semantic Release [PUBLISH]
uses: ./.github/actions/semantic
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
publish: true
deploy:
runs-on: ubuntu-latest
needs: release
if: github.ref == 'refs/heads/main' && (needs.release.outputs.release-outputs.new_release_published == 'true' || github.event.inputs.force-docker == true)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install node modules and run tests
run: |
npm ci --ignore-scripts
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Build and Push
id: docker_build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: |
godaddy/timings:latest
godaddy/timings:${{ needs.release.outputs.release-outputs.new_release_version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: |
echo Docker image was published sucessfully! >> $GITHUB_STEP_SUMMARY
echo - Image ID: **${{ steps.docker_build.outputs.imageid }}** >> $GITHUB_STEP_SUMMARY