Skip to content

Commit

Permalink
chore(template): sync with ahmadnassri/template-node-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Oct 12, 2021
1 parent 99652e0 commit 048fbef
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# ------------------------------------------------------------- #
# Note: this file is automatically managed in template-template #
# ------------------------------------------------------------- #

github: [ahmadnassri]
52 changes: 52 additions & 0 deletions .github/workflows/pull_request_target.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# ------------------------------------------------------------- #
# Note: this file is automatically managed in template-template #
# ------------------------------------------------------------- #

on: pull_request_target

name: pull_request_target

jobs:
metadata:
runs-on: ubuntu-latest

outputs:
repository: ${{ steps.metadata.outputs.repository }}

steps:
- uses: actions/[email protected]

- uses: ahmadnassri/action-metadata@v1
id: metadata

auto-merge:
timeout-minutes: 5

runs-on: ubuntu-latest

# only run for dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}

steps:
- uses: ahmadnassri/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}

template-sync:
needs: metadata

timeout-minutes: 20

runs-on: ubuntu-latest

# only run for templates
if: ${{ fromJSON(needs.metadata.outputs.repository).is_template }}

steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: ahmadnassri/[email protected]
- uses: ahmadnassri/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}
186 changes: 186 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# ------------------------------------------------------------- #
# Note: this file is automatically managed in template-node-lib #
# ------------------------------------------------------------- #

on:
- push
- workflow_dispatch

name: push

jobs:
metadata:
runs-on: ubuntu-latest

outputs:
repository: ${{ steps.metadata.outputs.repository }}

steps:
- uses: actions/[email protected]

- uses: ahmadnassri/action-metadata@v1
id: metadata

commit-lint:
timeout-minutes: 5

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: ahmadnassri/action-commit-lint@v1
with:
config: .github/linters/.commit-lint.yml

super-linter:
timeout-minutes: 5

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: github/super-linter/slim@v4
env:
LOG_LEVEL: ERROR
VALIDATE_ALL_CODEBASE: false
FILTER_REGEX_EXCLUDE: '/github/workspace/README.md|test/fixtures/*'
GITHUB_TOKEN: ${{ github.token }}

npm-audit:
timeout-minutes: 5

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/[email protected]

- run: npm audit --audit-level=critical

test-strategy:
needs:
- commit-lint
- super-linter
- npm-audit

timeout-minutes: 5

runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.parse.outputs.matrix }}

steps:
- uses: actions/checkout@v2
- id: parse
run: echo "::set-output name=matrix::$(jq -c . < .github/matrix.json)"

test-run:
needs: test-strategy

timeout-minutes: 5

name: ${{ matrix.name || format('node v{0} @ {1}', matrix.node-version, matrix.os) || 'test-step' }}

strategy:
matrix: ${{ fromJSON(needs.test-strategy.outputs.matrix) }}

runs-on: ${{ matrix.os }}

steps:
- uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}

- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ matrix.os }}-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- run: npm ci
- run: npm run test:ci

release:
needs: test-run

# only runs on main branch
if: ${{ github.ref == 'refs/heads/master' }}

timeout-minutes: 20

runs-on: ubuntu-latest

outputs:
published: ${{ steps.release.outputs.published }}
version: ${{ steps.release.outputs.release-version }}

steps:
- uses: actions/checkout@v2
with:
submodules: true

- id: release
uses: ahmadnassri/action-semantic-release@v1
with:
config: ${{ github.workspace }}/.semantic.json
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

mirror:
needs: release

timeout-minutes: 5

runs-on: ubuntu-latest

if: ${{ needs.release.outputs.published == 'true' }}

steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: ahmadnassri/action-github-registry-npm-proxy@v2
with:
token: ${{ secrets.GH_TOKEN }}
scope: ${{ github.repository_owner }}

- name: publish to github registry
run: |
jq '.name = "@'"${GITHUB_REPOSITORY/node-/}"'"' package.json > /tmp/package.json; mv /tmp/package.json .
npm version --no-git-tag-version v${{ needs.release.outputs.version }}
npm publish
template-sync:
timeout-minutes: 20

needs:
- metadata
- test-run
- commit-lint
- super-linter

# only runs on main branch and only for the template
if: ${{ github.ref == 'refs/heads/master' && fromJSON(needs.metadata.outputs.repository).is_template }}

runs-on: ubuntu-latest

steps:
- uses: ahmadnassri/[email protected]

- uses: actions/checkout@v2

- uses: ahmadnassri/[email protected]
with:
github-token: ${{ secrets.GH_TOKEN }}
11 changes: 11 additions & 0 deletions .pandoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
input-file: docs/README.md
output-file: README.md
metadata-file: colophon.yml
template: docs/README.template

from: gfm
to: gfm

wrap: preserve
reference-links: true
fail-if-warnings: false
21 changes: 8 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,25 @@ x-node: &node
services:
# ---- super-linter ---- #
lint:
image: github/super-linter:v3
image: github/super-linter:slim-v4
volumes:
- ./:/tmp/lint
- ./:/github/workspace
environment:
RUN_LOCAL: 'true'
LOG_LEVEL: 'ERROR'
MULTI_STATUS: 'false'
IGNORE_GITIGNORED_FILES: 'true'
DEFAULT_WORKSPACE: /github/workspace
FILTER_REGEX_EXCLUDE: '/github/workspace/README.md|test/fixtures/*'

# ---- readme generator ---- #
readme:
image: pandoc/core:2.11.4
image: pandoc/core:2.13
volumes:
- ./:/data
command: >-
--metadata-file=colophon.yml
--template=docs/README.template
--output=README.md
--from=gfm
--to=gfm
--fail-if-warnings
--wrap=preserve
--reference-links
docs/README.md
command: --defaults=.pandoc.yml

# ---- test runner ---- #
test:
<<: *node
image: node:alpine
Expand Down

0 comments on commit 048fbef

Please sign in to comment.