Skip to content

Commit

Permalink
ci: Streamline test -> image publish workflows
Browse files Browse the repository at this point in the history
Trigger publish workflow based on completion of separate test workflow
  • Loading branch information
FoxxMD committed Feb 21, 2024
1 parent fe9ae0b commit be1d6a7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
32 changes: 9 additions & 23 deletions .github/workflows/publishImage.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
name: Publish Docker image to Dockerhub and GHCR
name: Publish Container Images

on:
push:
workflow_run:
workflows:
- Test
types:
- completed
branches:
- 'main'
# add additional branches that should build to images here
# they will be tagged based on the branch name IE kener:test
- 'develop'
push:
tags:
- '*.*.*'
# don't trigger if just updating docs
paths-ignore:
- 'README.md'

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- name: Install dev dependencies
run: npm ci
- name: Test Backend
run: npm run test

push_to_registry:
name: Push Docker image to Docker Hub
name: Build and Push Images to Registries
runs-on: ubuntu-latest
needs: test
# only run if we've specified image tag to push to
if: ${{ vars.DOCKERHUB_IMAGE_NAME != '' || vars.GHCR_IMAGE_NAME != '' }}
if: ${{ (github.event_name === 'push' || github.event.workflow_run.conclusion == 'success') && (vars.DOCKERHUB_IMAGE_NAME != '' || vars.GHCR_IMAGE_NAME != '') }}
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions:
packages: write
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Publish Docker image to Dockerhub
name: Test

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- 'main'
- 'develop'
# don't trigger if just updating docs
paths-ignore:
- 'README.md'

jobs:
test:
Expand All @@ -18,7 +23,5 @@ jobs:
cache: 'npm'
- name: Install dev dependencies
run: npm ci
- name: Build Backend
run: 'npm run build:backend'
- name: Test Backend
- name: Test
run: npm run test
22 changes: 22 additions & 0 deletions .github/workflows/testPr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- name: Install dev dependencies
run: npm ci
- name: Test
run: npm run test

0 comments on commit be1d6a7

Please sign in to comment.