11name : CI Copier
22on :
33 pull_request :
4- push :
5- branches :
6- - main
4+ merge_group :
75
86# Automatically stop old builds on the same branch/PR
97concurrency :
@@ -51,14 +49,15 @@ jobs:
5149 strategy :
5250 matrix :
5351 minimal-python-version : [py38, py310]
54-
5552 steps :
5653 - name : Checkout branch
5754 uses : actions/checkout@v4
5855 with :
5956 ssh-key : ${{ secrets.SSH_PRIVATE_KEY }}
6057 - name : Set up pixi
6158 uses : prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
59+ with :
60+ activate-environment : true
6261 - name : Test generated package CI
6362 run : |
6463 # Name of the generated package.
7069 git config --global user.email "landocalrissian@example.com"
7170 git config --global user.name "Lando Calrissian"
7271 # Generate package with default settings + Windows CI.
73- pixi run copier copy \
72+ copier copy \
7473 --data project_name="Package" \
7574 --data project_short_description="Example Package" \
7675 --data github_user="LandoCalrissian" \
@@ -80,12 +79,17 @@ jobs:
8079 --trust \
8180 . out
8281 cd out
82+ # Replace actions trigger with on: [push]
83+ yq eval '.on = ["push"]' -i .github/workflows/ci.yml
84+ yq eval '.on = ["push"]' -i .github/workflows/build.yml
85+ git add .github/workflows/ci.yml .github/workflows/build.yml
86+ git commit -m "Replace actions trigger with on: [push]"
8387 # Push the generated package's HEAD commit to a `ci/*` branch
8488 cid=$(git rev-parse HEAD)
85- git push -f "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" $cid:refs/heads/ci/$GITHUB_SHA
89+ git push -f "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" $cid:refs/heads/ci/${ GITHUB_SHA}-${{ matrix.minimal-python-version }}
8690 # Use the GitHub API to wait for the generated package's CI to complete (success or failure).
8791 # We look for a GitHub Actions run for the HEAD commit ID.
88- WORKFLOW_URL="$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}&head_sha=${cid}"
92+ WORKFLOW_URL="$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}-${{ matrix.minimal-python-version }} &head_sha=${cid}"
8993 echo "Waiting for inner CI to start"
9094 while (( $(curl -Ls --header "$AUTH" "$WORKFLOW_URL" | jq -r ".workflow_runs | length") < 1 )); do
9195 sleep 10
@@ -106,9 +110,9 @@ jobs:
106110 eval $(ssh-agent)
107111 ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
108112
109- git push -d "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" refs/heads/ci/$GITHUB_SHA
113+ git push -d "${GITHUB_SERVER_URL/https:\/\//git@}:$GITHUB_REPOSITORY" refs/heads/ci/$GITHUB_SHA-${{ matrix.minimal-python-version }}
110114
111- for line in $(curl -Ls --header "$AUTH" "$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}&head_sha=${cid}" | jq -r ".workflow_runs | .[] | select(.status != \"completed\") | .id")
115+ for line in $(curl -Ls --header "$AUTH" "$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs?branch=ci/${GITHUB_SHA}-${{ matrix.minimal-python-version }} &head_sha=${cid}" | jq -r ".workflow_runs | .[] | select(.status != \"completed\") | .id")
112116 do
113117 curl -Ls --header "$AUTH" --request POST "$GITHUB_API_URL/repos/${GITHUB_REPOSITORY}/actions/runs/$line/cancel" > /dev/null
114118 done
0 commit comments