Skip to content

Commit 2fa682f

Browse files
committed
chore(IDX): replace checkout with changed files action
1 parent da11c73 commit 2fa682f

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

.github/workflows/internal_vs_external.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,28 @@ jobs:
6969
repository: dfinity/public-workflows
7070
path: public-workflows
7171

72-
# Then switch back to this repository to make sure it's run from current
73-
- name: Checkout Original Repository
74-
uses: actions/checkout@v4
75-
with:
76-
path: current-repo # need to specify another path to avoid overwriting the first checkout
77-
repository: ${{ github.event.pull_request.head.repo.full_name }}
78-
ref: ${{ github.head_ref }}
79-
fetch-depth: 256
80-
8172
- name: Python Setup
8273
uses: ./public-workflows/.github/workflows/python-setup
8374
with:
8475
working-directory: public-workflows
8576

77+
- name: Get changed files
78+
id: changed-files
79+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
80+
with:
81+
use_rest_api: 'true'
82+
8683
- name: Check External Changes
8784
id: check-external-changes
8885
run: |
8986
export PYTHONPATH="$PWD/public-workflows/reusable_workflows/"
9087
python public-workflows/reusable_workflows/repo_policies/check_external_changes.py
9188
shell: bash
9289
env:
90+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
9391
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # no actual token stored, read-only permissions
9492
ORG: ${{ github.repository_owner }}
9593
REPO: ${{ github.event.repository.name }}
96-
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
97-
BRANCH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
98-
REPO_PATH: current-repo
9994

10095
- name: Add PR Comment
10196
uses: actions/github-script@v7

reusable_workflows/repo_policies/check_external_changes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,14 @@ def check_files_against_blacklist(changed_files: list, blacklist_files: list) ->
6363

6464
def main():
6565
# Environment variables
66-
merge_base_sha = os.getenv("MERGE_BASE_SHA", "HEAD")
67-
branch_head_sha = os.getenv("BRANCH_HEAD_SHA", "")
68-
REQUIRED_ENV_VARS = ["REPO", "REPO_PATH", "ORG", "GH_TOKEN"]
66+
REQUIRED_ENV_VARS = ["REPO", "CHANGED_FILES", "ORG", "GH_TOKEN"]
6967
env_vars = load_env_vars(REQUIRED_ENV_VARS)
7068

7169
gh = github3.login(token=env_vars["GH_TOKEN"])
7270
repo = gh.repository(owner=env_vars["ORG"], repository=env_vars["REPO"])
7371

7472
# Get changed files
75-
changed_files = get_changed_files(merge_base_sha, branch_head_sha, env_vars["REPO_PATH"])
73+
changed_files = env_vars["CHANGED_FILES"].split(",")
7674
print(f"Changed files: {changed_files}")
7775

7876
blacklist_files = get_blacklisted_files(repo)

0 commit comments

Comments
 (0)