Skip to content

workflow

workflow #33

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags: [v*]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- main
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
env:
IMAGE_NAME: 'controller'
jobs:
Build:
runs-on: ubuntu-20.04
strategy:
matrix:
platform:
- linux/amd64
- linux/386
- linux/arm/v6
- linux/arm/v7
- linux/arm64
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
name: Preflight
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npm run standard
- run: |
npm i -g better-npm-audit
npx better-npm-audit audit -p
Tests:
needs: Build
runs-on: ubuntu-20.04
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
strategy:
matrix:
platform:
- linux/amd64
- linux/386
- linux/arm/v6
- linux/arm/v7
- linux/arm64
node: [ 16, 17, 16, 19,20, 21 ]
name: Node ${{ matrix.node }} Test
steps:
- uses: actions/checkout@v3
- name: Setup Node ${{ matrix.node }} Test
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Cache Node Modules
uses: actions/cache@v3
with:
path: |
node_modules
key: ${{ runner.os }}-controller-node_modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-controller-node_modules-
- run: npm install
- run: npm run test -- junit
- run: npm run postman_test
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
*-results.xml
Publish:
needs: [Build, Tests]
runs-on: ubuntu-20.04
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
strategy:
matrix:
platform:
- linux/amd64
- linux/386
- linux/arm/v6
- linux/arm/v7
- linux/arm64
name: Publish Controller
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Replace values
shell: bash
env:
PAT: ${{ secrets.PAT }}
run: |
sed -i.back "s|PAT|${PAT}|g" .npmrc
- run: npm install
- name: npm version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: package version
shell: bash
id: version
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
echo "pkg_version=${{ steps.package-version.outputs.current-version}}" >> "${GITHUB_OUTPUT}"
else
echo "pkg_version=${{ steps.package-version.outputs.current-version}}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: npm pack with version from package version
run: |
npm login --scope=@NAMESPACE --auth-type=legacy --registry=https://npm.pkg.github.com -u ${{ github.actor }} -p ${{ secrets.PAT }}
npm pack
npm publish
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.PAT }}
- name: Build and Push to ghcr
uses: docker/build-push-action@v3
id: build_push_ghcr
with:
file: Dockerfile.dev
platforms: ${{ matrix.platforms }}
push: true
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Proxy
tags: |
ghcr.io/datasance/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/datasance/${{ env.IMAGE_NAME }}:latest
ghcr.io/datasance/${{ env.IMAGE_NAME }}:main