Skip to content

Commit

Permalink
use reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Jun 10, 2023
1 parent d583225 commit a32706c
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 109 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-and-test.workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Build & Test
on:
workflow_call:
inputs:
working-directory:
required: false
type: string
default: '.'
jobs:
build_and_test:
name: Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ inputs.working-directory }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup env
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'

- name: Install dependencies
run: yarn install

- name: ESLint checks
run: yarn lint

- run: yarn build
name: Compile Typescript

- run: yarn test
name: Run tests
env:
CI: true

- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
---
name: Docker Publish Image
name: Docker Workflow
on:
push:
branches:
- main
tags:
- 'v*.*.*'

workflow_call:
inputs:
platforms:
required: true
type: string
push:
type: boolean
default: false
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
GITHUB_TOKEN:
required: true
jobs:
docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,8 +59,8 @@ jobs:
with:
context: .
file: containers/wetty/Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
platforms: ${{ inputs.platforms }}
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ steps.meta.outputs.tags }}
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@ on:
branches:
- main
jobs:
build:
test:
name: Build & Test
uses: ./.github/workflows/build-and-test.workflow.yml

publish:
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

# Test & Link package
- name: Setup env
uses: actions/setup-node@v3
with:
node-version: 14
- run: yarn
name: Install dependencies
- name: ESLint checks
run: yarn lint
- run: yarn build
name: Compile Typescript
- run: yarn test
name: Run tests
env:
CI: true
node-version: 18
cache: 'yarn'

- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}

# Publish to NPM
- name: Publish if version has been updated
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Run tests
on:
pull_request:
jobs:
test:
name: Build & Test
uses: ./.github/workflows/build-and-test.workflow.yml

validate-docker:
name: Validate Docker Build
uses: ./.github/workflows/docker.workflow.yml
strategy:
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
secrets: inherit
with:
platforms: ${{ matrix.platform }}
push: false
26 changes: 0 additions & 26 deletions .github/workflows/rebase.yml

This file was deleted.

12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ on:
tags:
- 'v*.*.*'
jobs:
Release:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create Release
uses: fregante/release-with-changelog@v3
with:
Expand All @@ -24,3 +22,11 @@ jobs:
{commits}
{range}
docker:
name: Docker Publish Image
uses: ./.github/workflows/docker.workflow.yml
secrets: inherit
with:
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
1 change: 0 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v8
with:
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/test.yml

This file was deleted.

0 comments on commit a32706c

Please sign in to comment.