Skip to content

Commit

Permalink
ci: fix run conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 14, 2024
1 parent 22fbf0d commit 1a70cbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ on:
types:
- opened
- edited
paths:
- app/**
- i18n/**
- gradle/**
workflow_dispatch:

permissions: {}

env:
RUN_LINT: "yes"

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request_target' || github.event.pull_request.draft == false

steps:
- uses: actions/checkout@v4
Expand All @@ -42,18 +44,7 @@ jobs:
- name: 🚧 Do prerequisites
run: npm ci

- name: 🚧 Disable lint on draft pull request
if: github.event_name == 'pull_request_target' && github.event.pull_request.draft == true
run: echo "RUN_LINT=no" >> $GITHUB_ENV

- name: 🔎 Check pull request changes
if: github.event_name == 'pull_request_target' && github.event.pull_request.draft == false
run: |
git fetch origin "${{ github.base_ref }}" --depth=1
echo "RUN_LINT=$(npm run --silent git:diff-files-yn 'origin/${{ github.base_ref }}' 'app/' 'i18n/' 'gradle/')" >> $GITHUB_ENV
- name: 🚨 Analyze code
if: env.RUN_LINT == 'no'
run: |
npm run prebuild
chmod +x ./gradlew
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/i18n-summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,35 @@ on:
types:
- opened
- edited
paths:
- .phrasey/**
- i18n/**
workflow_dispatch:

permissions:
contents: write
pull-requests: write

env:
PR_COMMENT: "no"
RUN_SUMMARY: "yes"

jobs:
i18n-summary:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request_target' || github.event.pull_request.draft == false

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "18.13.0"
node-version: 20.x
cache: npm

- name: 🏗️ Prerequisites
run: npm install
- name: 🚧 Do prerequisites
run: npm ci

- name: 🔨 Build
- name: 🚨 Analyze i18n
run: npm run i18n:summary

- name: 🚀 Push summary files
Expand All @@ -47,14 +51,8 @@ jobs:
checkout-orphan: true
force: true

- name: 🔎 Check pull request changes
if: github.event_name == 'pull_request_target' && github.event.pull_request.draft == false
run: |
git fetch origin "${{ github.base_ref }}" --depth=1
echo "PR_COMMENT=$(npm run --silent git:diff-files-yn 'origin/${{ github.base_ref }}' '.phrasey/' 'i18n/')" >> $GITHUB_ENV
- name: 💬 Comment summary
if: env.PR_COMMENT == 'yes'
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
Expand Down

0 comments on commit 1a70cbe

Please sign in to comment.