Skip to content

Merge pull request #12 from opencastsoftware/renovate/koa-logger-3.x #287

Merge pull request #12 from opencastsoftware/renovate/koa-logger-3.x

Merge pull request #12 from opencastsoftware/renovate/koa-logger-3.x #287

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- main
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Install Node
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version-file: .node-version
cache: npm
- name: Set NODE_VERSION
run: echo "NODE_VERSION=$(cat .node-version)" >> "$GITHUB_ENV"
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test
run: npm run test -- --coverage
- name: Get base image digest
id: get-digest
run: |
podman pull node:${{ env.NODE_VERSION }}-alpine
DIGEST=$(podman images --filter=reference="node:${{ env.NODE_VERSION }}-alpine" --digests --format json | jq -r '.[0].Digest')
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
- name: Get tag version
id: get-tag
run: |
TAG=$(echo ${{ github.ref_name }} | cut -c 2-)
echo "tag-version=$TAG" >> "$GITHUB_OUTPUT"
- name: Get build timestamp
id: get-timestamp
run: |
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "timestamp=$TIMESTAMP" >> "$GITHUB_OUTPUT"
- name: Build container image
id: build-image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
with:
image: govuk-nunjucks-renderer
tags: latest ${{ github.sha }} ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') && steps.get-tag.outputs.tag-version || '' }}
labels: |
org.opencontainers.image.created=${{ steps.get-timestamp.outputs.timestamp }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.base.name=docker.io/library/node:${{ env.NODE_VERSION }}-alpine
org.opencontainers.image.base.digest=${{ steps.get-digest.outputs.digest }}
${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') && format('org.opencontainers.image.version={0}', steps.get-tag.outputs.tag-version) || '' }}
containerfiles: ./Containerfile
build-args: |
NODE_VERSION=${{ env.NODE_VERSION }}
- name: Push image to GitHub Packages
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v')
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2
with:
registry: ghcr.io/opencastsoftware
username: ${{ github.actor }}
password: ${{ github.token }}
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
- name: Upload Coverage Report
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload Test Results
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
if: always()
with:
name: test-results
path: junit.xml