Skip to content

Pin dependencies

Pin dependencies #44

Workflow file for this run

name: CI
on:
push:
pull_request:
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
fetch-depth: 0
- name: Install Node
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
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 -- --ci --coverage --reporters=default --reporters=jest-junit
- 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@ab904c41d6ece82784817410c45d8b8c02684457 # v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload Test Results
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3
if: always()
with:
name: test-results
path: junit.xml