Skip to content

Ci: Add GitHub Actions CI/CD pipeline. #5

Ci: Add GitHub Actions CI/CD pipeline.

Ci: Add GitHub Actions CI/CD pipeline. #5

Workflow file for this run

name: CI
permissions:
id-token: write # Required for signing
contents: read
packages: write
attestations: write
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NODE_VERSION: "22"
jobs:
# --------
# CHECKS
# --------
checks:
name: Lint and Test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Enable Corepack
run: corepack enable
- name: Install Dependencies
run: yarn install --immutable
- name: Lint
run: yarn lint
- name: Test
run: yarn test
# -----------
# BUILD IMAGE
# -----------
# Multi-arch and attestation are required for OCP.
build-image:
name: Build Image
needs: checks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Build Image
uses: docker/build-push-action@v6
with:
context: .
push: false
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# -------------
# PUBLISH IMAGE
# -------------
publish:
name: Publish Image
needs: build-image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
tags: |
ghcr.io/twogiants/console-functions-plugin:latest
ghcr.io/twogiants/console-functions-plugin:sha-${{ github.sha }}
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v3
with:
subject-name: ghcr.io/twogiants/console-functions-plugin
subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true