Skip to content

Commit

Permalink
feat: pr-checks github action
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-j-baker committed Dec 20, 2024
1 parent 6e518a0 commit 7813b50
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/build-fsir-frontend.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
name: Build Future SIR frontend

on:
push:
branches:
- main
paths:
- .github/workflows/build-fsir-frontend.yaml
- future-sir-frontend/**
pull_request:
branches:
- main
paths:
- .github/workflows/build-fsir-frontend.yaml
- future-sir-frontend/**
workflow_call: {}
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI: true

jobs:
build-future-sir-frontend:
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR checks

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

jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.check-paths.outputs.frontend }}
gitops: ${{ steps.check-paths.outputs.gitops }}
infrastructure: ${{ steps.check-paths.outputs.infrastructure }}
steps:
- uses: actions/checkout@v4
- id: check-paths
uses: actions/github-script@v7
with:
script: |
const response = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const files = response.data.map(file => file.filename);
const hasFrontendChanges = files.some(file => file.startsWith('future-sir-frontend/'));
const hasGitopsChanges = files.some(file => file.startsWith('future-sir-gitops/'));
const hasInfrastructureChanges = files.some(file => file.startsWith('future-sir-infrastructure/'));
core.setOutput('frontend', hasFrontendChanges);
core.setOutput('gitops', hasGitopsChanges);
core.setOutput('infrastructure', hasInfrastructureChanges);
build-frontend:
needs: check-changes
if: ${{ needs.check-changes.outputs.frontend == 'true' }}
uses: ./.github/workflows/build-fsir-frontend.yaml

scan-frontend:
needs: check-changes
if: ${{ needs.check-changes.outputs.frontend == 'true' }}
uses: ./.github/workflows/scan-fsir-frontend.yaml
18 changes: 3 additions & 15 deletions .github/workflows/scan-fsir-frontend.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
name: Scan Future SIR frontend

on:
push:
branches:
- main
paths:
- .github/workflows/scan-fsir-frontend.yaml
- future-sir-frontend/**
pull_request:
branches:
- main
paths:
- .github/workflows/scan-fsir-frontend.yaml
- future-sir-frontend/**
workflow_call: {}
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI: true

jobs:
scan-future-sir-frontend:
Expand Down

0 comments on commit 7813b50

Please sign in to comment.