Skip to content

Commit

Permalink
fix(workflows): unwrap if conditions (#37768)
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner authored Jan 23, 2025
1 parent c2da4cc commit e4a2476
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/pr-check-lint_content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ jobs:
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- name: Checkout HEAD
if: ${{ env.DIFF_DOCUMENTS }}
if: env.DIFF_DOCUMENTS
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr_head

- name: Get changed content from HEAD
if: ${{ env.DIFF_DOCUMENTS }}
if: env.DIFF_DOCUMENTS
run: |
git config --global user.email "[email protected]"
git config --global user.name "mdn-bot"
Expand All @@ -62,21 +62,21 @@ jobs:
git commit -m "Code from PR head"
- name: Setup Node.js environment
if: ${{ env.DIFF_DOCUMENTS }}
if: env.DIFF_DOCUMENTS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Install all yarn packages
if: ${{ env.DIFF_DOCUMENTS }}
if: env.DIFF_DOCUMENTS
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint and format markdown files
if: ${{ env.DIFF_DOCUMENTS }}
if: env.DIFF_DOCUMENTS
run: |
# Generate random delimiter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
Expand Down Expand Up @@ -120,13 +120,13 @@ jobs:
git diff
- name: Setup reviewdog
if: ${{ env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' }}
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true'
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Suggest changes using diff
if: ${{ env.FILES_MODIFIED == 'true' }}
if: env.FILES_MODIFIED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand All @@ -141,7 +141,7 @@ jobs:
-reporter=github-pr-review < "${TMPFILE}"
- name: Add reviews for markdownlint errors
if: ${{ env.MD_LINT_FAILED == 'true' }}
if: env.MD_LINT_FAILED == 'true'
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand All @@ -154,7 +154,7 @@ jobs:
-reporter="github-pr-review"
- name: Fail if any issues pending
if: ${{ env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' || env.FM_LINT_FAILED == 'true' }}
if: env.FILES_MODIFIED == 'true' || env.MD_LINT_FAILED == 'true' || env.FM_LINT_FAILED == 'true'
env:
MD_LINT_FAILED: ${{ env.MD_LINT_FAILED }}
FM_LINT_FAILED: ${{ env.FM_LINT_FAILED }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/pr-review-companion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
review:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: "Download artifact"
uses: actions/download-artifact@v4
Expand All @@ -26,26 +26,26 @@ jobs:
run-id: ${{ github.event.workflow_run.id }}

- name: Check for artifacts
if: ${{ hashFiles('build/') != '' }}
if: hashFiles('build/') != ''
run: |
echo "HAS_ARTIFACT=true" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
with:
repository: mdn/yari
path: yari

- name: Install Python
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"

# See https://www.peterbe.com/plog/install-python-poetry-github-actions-faster
- name: Load cached ~/.local
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
uses: actions/cache@v4
with:
path: ~/.local
Expand All @@ -54,14 +54,14 @@ jobs:
key: dotlocal-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-0

- name: Install Python poetry
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
Expand All @@ -71,19 +71,19 @@ jobs:
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ steps.setup-python.outputs.python-version }}-0

- name: Install poetry dependencies
if: ${{ env.HAS_ARTIFACT && steps.cached-poetry-dependencies.outputs.cache-hit != 'true' }}
if: env.HAS_ARTIFACT && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
cd yari/deployer
poetry install --no-interaction --no-root
- name: Install Deployer
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
run: |
cd yari/deployer
poetry install --no-interaction
- name: Deploy and analyze built content
if: ${{ env.HAS_ARTIFACT }}
if: env.HAS_ARTIFACT
env:
BUILD_OUT_ROOT: ${{ github.workspace }}/build

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr-test-new-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Build changed content
id: build-content
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
env:
CONTENT_ROOT: ${{ github.workspace }}/files

Expand Down Expand Up @@ -119,21 +119,21 @@ jobs:
wget https://github.com/${{ github.repository }}/compare/${BASE_SHA}...${HEAD_SHA}.diff -O ${BUILD_OUT_ROOT}/DIFF
- name: Merge static assets with built documents
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
run: |
# Exclude the .map files, as they're used for debugging JS and CSS.
rsync -a --exclude "*.map" node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT
# Show the final disk usage size of the build.
du -sh $BUILD_OUT_ROOT
- uses: actions/upload-artifact@v4
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
with:
name: build
path: ${{ env.BUILD_OUT_ROOT }}

- name: Check changed files
if: ${{ env.GIT_DIFF_FILES }}
if: env.GIT_DIFF_FILES
run: |
echo $GIT_DIFF_FILES
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js environment
if: ${{ env.GIT_DIFF_CONTENT }} || ${{ env.GIT_DIFF_FILES }}
if: env.GIT_DIFF_CONTENT || env.GIT_DIFF_FILES
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn

- name: Install all yarn packages
if: ${{ env.GIT_DIFF_CONTENT }} || ${{ env.GIT_DIFF_FILES }}
if: env.GIT_DIFF_CONTENT || env.GIT_DIFF_FILES
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build changed content
id: build-content
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
env:
CONTENT_ROOT: ${{ github.workspace }}/files

Expand Down Expand Up @@ -112,21 +112,21 @@ jobs:
wget https://github.com/${{ github.repository }}/compare/${BASE_SHA}...${HEAD_SHA}.diff -O ${BUILD_OUT_ROOT}/DIFF
- name: Merge static assets with built documents
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
run: |
# Exclude the .map files, as they're used for debugging JS and CSS.
rsync -a --exclude "*.map" node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT
# Show the final disk usage size of the build.
du -sh $BUILD_OUT_ROOT
- uses: actions/upload-artifact@v4
if: ${{ env.GIT_DIFF_CONTENT }}
if: env.GIT_DIFF_CONTENT
with:
name: build
path: ${{ env.BUILD_OUT_ROOT }}

- name: Check changed files
if: ${{ env.GIT_DIFF_FILES }}
if: env.GIT_DIFF_FILES
run: |
echo $GIT_DIFF_FILES
Expand Down

0 comments on commit e4a2476

Please sign in to comment.