|
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | + schedule: |
| 4 | + - cron: 0 1 * * 6 |
| 5 | + |
| 6 | +name: "Bump CUDA-Q Commit" |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-cudaq-commit: |
| 10 | + name: Bump CUDA-Q Commit |
| 11 | + runs-on: ubuntu-latest |
| 12 | + if: ${{ github.repository == 'NVIDIA/cudaqx' }} |
| 13 | + permissions: |
| 14 | + contents: write # Required to push changes |
| 15 | + pull-requests: write # Required to open PRs |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + ref: main |
| 22 | + |
| 23 | + - name: Fetch the latest commit |
| 24 | + run: | |
| 25 | + SHA=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/main" | jq -r '.sha') |
| 26 | + echo "Latest SHA: $SHA" |
| 27 | + echo "sha=$SHA" >> $GITHUB_ENV |
| 28 | +
|
| 29 | + - name: Check if SHA has changed |
| 30 | + id: check_change |
| 31 | + run: | |
| 32 | + CURRENT_SHA=$(jq -r '.cudaq.ref' .cudaq_version) |
| 33 | + if [[ "${{ env.LATEST_SHA }}" == "$CURRENT_SHA" ]]; then |
| 34 | + echo "No changes in SHA. Skipping PR creation." |
| 35 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "SHA has changed. Proceeding to create PR." |
| 38 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 39 | + fi |
| 40 | +
|
| 41 | + - name: Update .cudaq_version file |
| 42 | + if: ${{ steps.check_change.outputs.changed == 'true' }} |
| 43 | + run: | |
| 44 | + jq '.cudaq.ref = "${{ env.sha }}"' .cudaq_version > .cudaq_version.tmp |
| 45 | + mv .cudaq_version.tmp .cudaq_version |
| 46 | + echo "Updated SHA in .cudaq_version" |
| 47 | +
|
| 48 | + - name: Commit and push changes |
| 49 | + if: ${{ steps.check_change.outputs.changed == 'true' }} |
| 50 | + run: | |
| 51 | + git config --global user.email "[email protected]" |
| 52 | + git config --global user.name "GitHub Action" |
| 53 | + BRANCH_NAME="update-cudaq-sha-$(date +%s)" |
| 54 | + git checkout -b $BRANCH_NAME |
| 55 | + git add .cudaq_version |
| 56 | + git commit -m "Update dependency SHA to ${{ env.sha }}" |
| 57 | + git push origin $BRANCH_NAME |
| 58 | +
|
| 59 | + - name: Create Pull Request |
| 60 | + if: ${{ steps.check_change.outputs.changed == 'true' }} |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ github.token }} |
| 63 | + run: | |
| 64 | + gh pr create \ |
| 65 | + --title "Bump CUDA-Q commit" \ |
| 66 | + --body "Auto update to the latest CUDA-Q commit" \ |
| 67 | + --head "${BRANCH_NAME}" \ |
| 68 | + --base "main" |
0 commit comments