Skip to content

Commit

Permalink
ci: make GitHub workflows modular
Browse files Browse the repository at this point in the history
  • Loading branch information
RalphORama committed Dec 22, 2023
1 parent 88ed02b commit ed0fc02
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 65 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build

on:
push:
# release pipeline calls build so don't run it twice
branches-ignore: ["main"]
pull_request:
workflow_call:

jobs:
lint:
uses: ./.github/workflows/lint.yml

docker:
runs-on: ubuntu-latest
needs:
- lint
steps:
- uses: actions/checkout@v4

- name: Build Docker Image
run: docker build . --file Dockerfile --tag ghcr.io/podaboutlist/linkfix-for-discord:$(date +%s)
21 changes: 7 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: Lint TypeScript and build Dockerfile
on: [push, pull_request]
name: Lint

on:
workflow_call:

jobs:
prettier_lint:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
node-version: "lts/*"

- name: Cache NPM Dependencies
uses: actions/cache@v3
Expand All @@ -23,13 +26,3 @@ jobs:

- name: Lint src/**/*.ts with Prettier
run: npm run lint

docker_build:
runs-on: ubuntu-latest
# Don't try to build the Docker image unless linting succeeds
needs: prettier_lint
steps:
- uses: actions/checkout@v3

- name: Build Docker image
run: docker build . --file Dockerfile --tag ghcr.io/podaboutlist/linkfix-for-discord:$(date +%s)
51 changes: 0 additions & 51 deletions .github/workflows/publish-image.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
push:
branches: ["main"]
tags: ["**"]

jobs:
ghcr:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4

- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@master
with:
image_name: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit ed0fc02

Please sign in to comment.