Skip to content

Commit

Permalink
ci: update reusable workflows (#425)
Browse files Browse the repository at this point in the history
* ci: update reusable workflows

* ci: update documentation secrets
  • Loading branch information
favna authored Aug 17, 2024
1 parent 976e478 commit 2f58b74
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 356 deletions.
22 changes: 0 additions & 22 deletions .github/problemMatchers/eslint.json

This file was deleted.

17 changes: 0 additions & 17 deletions .github/problemMatchers/tsc.json

This file was deleted.

21 changes: 5 additions & 16 deletions .github/workflows/auto-deprecate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,8 @@ on:
jobs:
auto-deprecate:
name: NPM Auto Deprecate
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Deprecate versions
run: yarn npm-deprecate
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
with:
script-name: npm-deprecate
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
20 changes: 4 additions & 16 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Scanning
name: Code scanning

on:
push:
Expand All @@ -11,18 +11,6 @@ on:
- cron: '30 1 * * 0'

jobs:
CodeQL:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
codeql:
name: Analysis
uses: sapphiredev/.github/.github/workflows/reusable-codeql.yml@main
44 changes: 11 additions & 33 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,29 @@ on:
inputs:
prNumber:
description: The number of the PR that is being deployed
required: true
required: false
type: string
ref:
description: The branch that is being deployed. Should be a branch on the given repository
required: false
default: main
type: string
repository:
description: The {owner}/{repository} that is being deployed.
required: false
default: sapphiredev/pieces
type: string
push:
branches:
- main

jobs:
Publish:
name: Publish Next to npm
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.inputs.repository || 'sapphiredev/pieces' }}
ref: ${{ github.event.inputs.ref || 'main' }}
- name: Add TypeScript problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Bump Version & Publish
run: |
# Resolve the tag to be used. "next" for push events, "pr-{prNumber}" for dispatch events.
TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}')
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)" --skip-changelog
yarn npm publish --tag ${TAG}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: sapphiredev/.github/.github/workflows/reusable-continuous-delivery.yml@main
with:
pr-number: ${{ github.event.inputs.prNumber }}
ref: ${{ github.event.inputs.ref }}
repository: ${{ github.event.inputs.repository }}
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
80 changes: 23 additions & 57 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: CI

on:
push:
Expand All @@ -7,63 +7,29 @@ on:
pull_request:

jobs:
Linting:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Run ESLint
run: yarn lint --fix=false
uses: sapphiredev/.github/.github/workflows/reusable-lint.yml@main

docs:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Generate Documentation
run: yarn docs
name: Docgen
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
with:
script-name: docs

BuildingAndTesting:
name: Building and Testing with node v${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [18, 19, 20, 21]
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Typecheck And Build Code
run: yarn typecheck && yarn build
- name: Run tests
run: yarn test
build:
name: Building
uses: sapphiredev/.github/.github/workflows/reusable-build.yml@main

test:
name: Tests
uses: sapphiredev/.github/.github/workflows/reusable-tests.yml@main
with:
enable-sonar: true
secrets:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

typecheck:
name: Typecheck
uses: sapphiredev/.github/.github/workflows/reusable-typecheck.yml@main
22 changes: 5 additions & 17 deletions .github/workflows/deprecate-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ on:
jobs:
deprecate-on-merge:
name: NPM Deprecate PR versions On Merge
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Deprecate versions
run: yarn npm-deprecate --name "*pr-${PR_NUMBER}*" -d -v
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
with:
script-name: npm-deprecate --name "*pr-${{ github.event.number }}*" -d -v
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
107 changes: 6 additions & 101 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,105 +7,10 @@ on:
tags:
- 'v*'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
if: github.repository_owner == 'sapphiredev'
outputs:
NAME: ${{ steps.env.outputs.NAME }}
TYPE: ${{ steps.env.outputs.TYPE }}
SHA: ${{ steps.env.outputs.SHA }}
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Build Documentation
run: yarn docs
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/api.json
- name: Set Output
id: env
run: |
echo "NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
echo "TYPE=${GITHUB_REF_TYPE}" >> $GITHUB_OUTPUT
echo "SHA=${GITHUB_SHA}" >> $GITHUB_OUTPUT
upload:
name: Upload Documentation
needs: build
runs-on: ubuntu-latest
env:
NAME: ${{ needs.build.outputs.NAME }}
TYPE: ${{ needs.build.outputs.TYPE }}
SHA: ${{ needs.build.outputs.SHA }}
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.org/
- name: Install Dependencies
run: yarn --immutable
- name: Download Documentation Artifacts
uses: actions/download-artifact@v4
with:
name: docs
path: docs
- name: Checkout Documentation Project
uses: actions/checkout@v4
with:
repository: 'sapphiredev/docs'
token: ${{ secrets.SKYRA_TOKEN }}
path: 'out'

- name: Move Documentation
if: ${{ env.TYPE == 'tag' }}
env:
SEMVER: ${{ env.NAME }}
run: |
mkdir -p out/pieces
mv docs/api.json out/docs/pieces/${SEMVER}.json
- name: Move Documentation
if: ${{ env.TYPE == 'branch' }}
run: |
mkdir -p out/pieces
mv docs/api.json out/docs/pieces/${NAME}.json
- name: Commit & Push
uses: nick-fields/retry@v3
with:
max_attempts: 3
retry_on: error
timeout_minutes: 1
command: |
cd out
git add .
if git diff-index --quiet HEAD --; then
echo "No changes to commit, exiting with code 0"
exit 0;
else
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git config rebase.autostash true
git config pull.rebase true
git commit -m "docs(pieces): build for ${TYPE} ${NAME}: ${SHA}" || true
git pull
git push
fi
docgen:
uses: sapphiredev/.github/.github/workflows/reusable-docgen.yml@main
with:
project-name: pieces
secrets:
SKYRA_TOKEN: ${{ secrets.SKYRA_TOKEN }}
Loading

0 comments on commit 2f58b74

Please sign in to comment.