Skip to content

Commit a19c5f3

Browse files
authored
Remove use of compromised action (#19848)
* Remove use of compromised action * test changed file logic * success
1 parent d881aea commit a19c5f3

File tree

1 file changed

+33
-56
lines changed

1 file changed

+33
-56
lines changed

.github/workflows/build-deps.yml

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
fail-fast: false
6262
matrix:
6363
job:
64-
- os: arm-4core-linux
64+
- os: ubuntu-22.04-arm
6565
image: linux-aarch64
6666
- os: ubuntu-22.04
6767
image: linux-x86_64
@@ -85,92 +85,69 @@ jobs:
8585

8686
# On pull requests, ensure that changed files are determined before checking out the code so
8787
# that we use the GitHub API, otherwise we would have to fetch the entire history (depth: 0)
88-
- name: Get changed files
88+
- name: Check for builder changes (pull request)
89+
id: changed-files-pr
90+
if: github.event_name == 'pull_request'
91+
env:
92+
GH_TOKEN: "${{ github.token }}"
93+
run: |
94+
PR_NUMBER="${{ github.event.pull_request.number }}"
95+
REPO="${{ github.repository }}"
96+
97+
BUILDERS_CHANGED=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" | \
98+
jq -r 'map(.filename) | map(select(startswith(".builders/"))) | length > 0')
99+
100+
echo "builders_any_changed=$BUILDERS_CHANGED" >> $GITHUB_OUTPUT
101+
102+
# For push events, we still need to check changes but will rely on minimal checkout
103+
- name: Check for builder changes (push)
104+
id: changed-files-push
105+
if: github.event_name != 'pull_request'
106+
run: |
107+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
108+
echo "builders_any_changed=$(echo "$CHANGED_FILES" | grep -q "^\.builders/" && echo "true" || echo "false")" >> $GITHUB_OUTPUT
109+
110+
# Combine outputs for subsequent steps
111+
- name: Combine changed files outputs
89112
id: changed-files
90-
uses: tj-actions/changed-files@v42
91-
with:
92-
files_yaml: |-
93-
builders:
94-
- .builders/**
95-
dependencies:
96-
- ${{ env.DIRECT_DEPENDENCY_FILE }}
113+
run: |
114+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
115+
echo "builders_any_changed=${{ steps.changed-files-pr.outputs.builders_any_changed }}" >> $GITHUB_OUTPUT
116+
else
117+
echo "builders_any_changed=${{ steps.changed-files-push.outputs.builders_any_changed }}" >> $GITHUB_OUTPUT
118+
fi
97119
98120
- name: Checkout code
99121
if: github.event_name == 'pull_request'
100122
uses: actions/checkout@v4
101123

102124
- name: Set up Python ${{ env.PYTHON_VERSION }}
103-
if: matrix.job.image != 'linux-aarch64'
104125
uses: actions/setup-python@v5
105126
with:
106127
python-version: ${{ env.PYTHON_VERSION }}
107128

108-
- name: Set up Python (with miniconda) and other aarch64 requirements
109-
if: matrix.job.image == 'linux-aarch64'
110-
run: |
111-
mkdir -p ~/miniconda3
112-
wget https://repo.anaconda.com/miniconda/Miniconda3-py312_24.5.0-0-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh
113-
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
114-
rm -rf ~/miniconda3/miniconda.sh
115-
~/miniconda3/bin/conda init bash
116-
117-
# jq
118-
wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64 -O ~/miniconda3/bin/jq
119-
chmod +x ~/miniconda3/bin/jq
120-
121-
echo "PATH=~/miniconda3/bin/:${PATH}" >> "$GITHUB_ENV"
122-
echo DOCKER="sudo docker" >> "$GITHUB_ENV"
123-
124129
- name: Install management dependencies
125130
run: |
126131
pip install -r .builders/deps/host_dependencies.txt
127132
128-
- name: Install docker and log in (arm64)
129-
if: matrix.job.image == 'linux-aarch64'
130-
run: |
131-
curl -fsSL https://get.docker.com -o get-docker.sh
132-
sudo sh get-docker.sh
133-
134-
# Logging in with sudo is necessary to get authorized with the registry when running docker under sudo
135-
echo ${{ secrets.GITHUB_TOKEN }} | sudo docker login --username ${{ github.actor }} --password-stdin ghcr.io
136-
137133
- name: Log in to GitHub Packages
138-
if: matrix.job.image != 'linux-aarch64'
139134
uses: docker/login-action@v3
140135
with:
141136
registry: ghcr.io
142137
username: ${{ github.actor }}
143138
password: ${{ secrets.GITHUB_TOKEN }}
144139

145-
- name: Build image and wheels (arm64)
146-
if: steps.changed-files.outputs.builders_any_changed == 'true' && matrix.job.image == 'linux-aarch64'
147-
run: |-
148-
sudo /home/runner/miniconda3/bin/python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3
149-
# Give ownership of the output back to the user
150-
sudo chown ${USER} ${{ env.OUT_DIR }}
151-
152-
- name: Pull image and build wheels (arm64)
153-
if: steps.changed-files.outputs.builders_any_changed != 'true' && matrix.job.image == 'linux-aarch64'
154-
run: |-
155-
digest=$(jq -r '.["${{ matrix.job.image }}"]' .deps/image_digests.json)
156-
sudo /home/runner/miniconda3/bin/python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3 --digest $digest
157-
158140
- name: Build image and wheels
159-
if: steps.changed-files.outputs.builders_any_changed == 'true' && matrix.job.image != 'linux-aarch64'
141+
if: steps.changed-files.outputs.builders_any_changed == 'true'
160142
run: |-
161143
python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3
162144
163145
- name: Pull image and build wheels
164-
if: steps.changed-files.outputs.builders_any_changed != 'true' && matrix.job.image != 'linux-aarch64'
146+
if: steps.changed-files.outputs.builders_any_changed != 'true'
165147
run: |-
166148
digest=$(jq -r '.["${{ matrix.job.image }}"]' .deps/image_digests.json)
167149
python .builders/build.py ${{ matrix.job.image }} --python 3 ${{ env.OUT_DIR }}/py3 --digest $digest
168150
169-
- name: Change permissions
170-
if: matrix.job.image == 'linux-aarch64'
171-
run: |
172-
sudo chmod 777 ${{ env.OUT_DIR }}
173-
174151
- name: Publish image
175152
if: github.event_name == 'push' && steps.changed-files.outputs.builders_any_changed == 'true'
176153
run: ${DOCKER} push ${{ env.BUILDER_IMAGE }}

0 commit comments

Comments
 (0)