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 22, 2021
1 parent c4bf307 commit df6c0fc
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 22 deletions.
86 changes: 77 additions & 9 deletions .github/workflows/push.yml
@@ -1,6 +1,6 @@
# ------------------------------------------------------------- #
# Note: this file is automatically managed in template-node-lib #
# ------------------------------------------------------------- #
# ----------------------------------------------- #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #

on:
- push
Expand All @@ -14,12 +14,17 @@ jobs:

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

steps:
- uses: actions/checkout@v2.3.5

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

- id: dockerfile
run: |
[[ -f "${{ github.workspace }}/Dockerfile" ]] && echo '::set-output name=exists::yes' || exit 0
commit-lint:
timeout-minutes: 5
Expand Down Expand Up @@ -112,10 +117,12 @@ jobs:
- run: npm run test:ci

release:
needs: test-run
needs:
- metadata
- test-run

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

timeout-minutes: 20

Expand Down Expand Up @@ -160,9 +167,70 @@ jobs:
- 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 version --no-git-tag-version "v${{ needs.release.outputs.version }}"
npm publish
publish-docker:
needs:
- release
- metadata

timeout-minutes: 5

runs-on: ubuntu-latest

if: ${{ needs.metadata.outputs.dockerfile == 'yes' }}

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

- uses: actions/cache@v2.1.6
with:
path: /tmp/.buildx-cache
key: buildx-${{ github.sha }}
restore-keys: buildx-

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1

# login to docker hub
- uses: docker/login-action@v1
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}

# login to github container registry
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}

- id: hub
run: |
echo "::set-output name=name::$(basename "${GITHUB_REPOSITORY/node-//}")"
echo "::set-output name=version::${{ needs.release.outputs.version }}"
# publish
- uses: docker/build-push-action@v2
with:
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: |
${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:latest
${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ steps.hub.outputs.version }}
ghcr.io/${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ steps.hub.outputs.name }}:${{ steps.hub.outputs.version }}
labels: |
org.opencontainers.image.title=${{ steps.hub.outputs.name }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ steps.hub.outputs.version }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
template-sync:
timeout-minutes: 20

Expand Down
6 changes: 3 additions & 3 deletions .gitignore
@@ -1,6 +1,6 @@
# ----------------------------------------------------------- #
# Note: this file originates in ahmadnassri/template-node-lib #
# ----------------------------------------------------------- #
# ----------------------------------------------- #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #

.nyc_output
coverage
Expand Down
2 changes: 1 addition & 1 deletion .pandoc.yml
@@ -1,5 +1,5 @@
# ----------------------------------------------- #
# Note: this file originates in template-template #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #

input-file: docs/README.md
Expand Down
6 changes: 3 additions & 3 deletions .taprc.yml
@@ -1,6 +1,6 @@
# ----------------------------------------------------------- #
# Note: this file originates in ahmadnassri/template-node-lib #
# ----------------------------------------------------------- #
# ----------------------------------------------- #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #

ts: false
jsx: false
Expand Down
10 changes: 4 additions & 6 deletions docker-compose.yml
@@ -1,6 +1,6 @@
# ----------------------------------------------------------- #
# Note: this file originates in ahmadnassri/template-node-lib #
# ----------------------------------------------------------- #
# ----------------------------------------------- #
# Note: this file originates in template-node-lib #
# ----------------------------------------------- #

version: '3.8'

Expand All @@ -16,14 +16,13 @@ x-node: &node
services:
# ---- super-linter ---- #
lint:
image: github/super-linter:slim-v4
image: github/super-linter:v3
volumes:
- ./:/github/workspace
environment:
RUN_LOCAL: 'true'
LOG_LEVEL: 'ERROR'
MULTI_STATUS: 'false'
VALIDATE_JSCPD: 'false'
IGNORE_GITIGNORED_FILES: 'true'
DEFAULT_WORKSPACE: /github/workspace
FILTER_REGEX_EXCLUDE: '/github/workspace/README.md|test/fixtures/*'
Expand All @@ -35,7 +34,6 @@ services:
- ./:/data
command: --defaults=.pandoc.yml

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

0 comments on commit df6c0fc

Please sign in to comment.