Skip to content

Commit 0fdb9fd

Browse files
committed
Implement changes in other jobs too
1 parent 1f2cd5d commit 0fdb9fd

File tree

4 files changed

+51
-37
lines changed

4 files changed

+51
-37
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Checkout target repo and GitHub Actions repo
2+
3+
outputs:
4+
NAME:
5+
description: The target repo where this workflow is running (repo name w/o org prefix)
6+
value: ${{ steps.repo.outputs.NAME }}
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Get target repo name
12+
id: repo
13+
run: echo "NAME=$(basename ${{ github.repository }})" >> "$GITHUB_OUTPUT"
14+
shell: bash
15+
16+
# v4.2.2
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
19+
with:
20+
path: ${{ steps.repo.outputs.NAME }}
21+
22+
- name: Checkout Expensify/GitHub-Actions
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
24+
with:
25+
repository: Expensify/GitHub-Actions
26+
path: GitHub-Actions
27+
ref: Rory-ValidateGitHubActionsAnyRepo

.github/scripts/actionlint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ readonly SCRIPT_DIR
1414

1515
# To update the actionlint version, replace this file with the updated checksums file from the GitHub release
1616
readonly CHECKSUMS_FILE="$SCRIPT_DIR/actionlint_checksums.txt"
17-
readonly ACTIONLINT_PATH="$HOME/.local/bin/actionlint"
17+
readonly ACTIONLINT_PATH="$SCRIPT_DIR/actionlint"
18+
readonly REPO_ROOT="${REPO_ROOT:-.}"
1819

1920
source "$SCRIPT_DIR/shellUtils.sh"
2021

@@ -81,6 +82,7 @@ fi
8182

8283
info "Linting workflows..."
8384
echo
85+
cd "$REPO_ROOT" || exit 1
8486
if ! "$ACTIONLINT_PATH" -color; then
8587
error "Workflows did not pass actionlint :("
8688
exit 1

.github/scripts/validateImmutableActionRefs.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
77
readonly SCRIPT_DIR
88

9+
readonly REPO_ROOT="${REPO_ROOT:-.}"
10+
911
source "$SCRIPT_DIR/shellUtils.sh"
1012

1113
title "Checking for mutable action references..."
@@ -14,13 +16,13 @@ ACTION_USAGES=""
1416

1517
# Find yaml files - these can be either:
1618
# - workflows, which are always stored in .github/workflows, or
17-
WORKFLOWS="$(find .github/workflows -type f \( -name "*.yml" -o -name "*.yaml" \))"
19+
WORKFLOWS="$(find "$REPO_ROOT/.github/workflows" -type f \( -name "*.yml" -o -name "*.yaml" \))"
1820
if [[ -z "$WORKFLOWS" ]]; then
1921
warning "No workflows found. Did you remember to run this script from the root of a repository?" >&2
2022
fi
2123

2224
# - action metadata files, which can be anywhere in the repo, but must be called action.yml or action.yaml
23-
ACTIONS="$(find . -type f \( -name "action.yml" -o -name "action.yaml" \))"
25+
ACTIONS="$(find "$REPO_ROOT" -type f \( -name "action.yml" -o -name "action.yaml" \))"
2426
if [[ -z "$ACTIONS" ]]; then
2527
warning "No workflows found. Did you remember to run this script from the root of a repository?" >&2
2628
fi

.github/workflows/validateActions.yml

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,9 @@ jobs:
1010
validateSchemas:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- run: |
14-
set -x
15-
pwd
16-
ls
17-
18-
# v4.2.2
19-
- name: Checkout
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
21-
with:
22-
path: main
23-
24-
- name: Checkout Expensify/GitHub-Actions
25-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
26-
with:
27-
repository: Expensify/GitHub-Actions
28-
path: GitHub-Actions
29-
ref: Rory-ValidateGitHubActionsAnyRepo
30-
31-
- run: |
32-
set -x
33-
pwd
34-
ls
35-
ls main
36-
tree -a GitHub-Actions
13+
- name: Checkout repos
14+
id: repo
15+
uses: Expensify/GitHub-Actions/.github/composite/checkoutRepoAndGitHubActions@Rory-ValidateGitHubActionsAnyRepo
3716

3817
# v4.3.0
3918
- name: Setup Node
@@ -44,26 +23,30 @@ jobs:
4423
run: npm i -g ajv-cli@5.0.0
4524

4625
- name: Validate action and workflow schemas
47-
run: bash -x GitHub-Actions/.github/scripts/validateWorkflowSchemas.sh
26+
run: GitHub-Actions/.github/scripts/validateWorkflowSchemas.sh
4827
env:
49-
REPO_ROOT: main
28+
REPO_ROOT: ${{ steps.repo.outputs.NAME }}
5029

5130
actionlint:
5231
runs-on: ubuntu-latest
5332
steps:
54-
# v4.2.2
55-
- name: Checkout
56-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
33+
- name: Checkout repos
34+
id: repo
35+
uses: Expensify/GitHub-Actions/.github/composite/checkoutRepoAndGitHubActions@Rory-ValidateGitHubActionsAnyRepo
5736

5837
- name: Lint workflows with actionlint
59-
run: .github/scripts/actionlint.sh
38+
run: GitHub-Actions/.github/scripts/actionlint.sh
39+
env:
40+
REPO_ROOT: ${{ steps.repo.outputs.NAME }}
6041

6142
validateImmutableActionRefs:
6243
runs-on: ubuntu-latest
6344
steps:
64-
# v4.2.2
65-
- name: Checkout
66-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
45+
- name: Checkout repos
46+
id: repo
47+
uses: Expensify/GitHub-Actions/.github/composite/checkoutRepoAndGitHubActions@Rory-ValidateGitHubActionsAnyRepo
6748

6849
- name: Validate actions refs are immutable
69-
run: .github/scripts/validateImmutableActionRefs.sh
50+
run: GitHub-Actions/.github/scripts/validateImmutableActionRefs.sh
51+
env:
52+
REPO_ROOT: ${{ steps.repo.outputs.NAME }}

0 commit comments

Comments
 (0)