|
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | + pull_request: |
| 4 | + #schedule: |
| 5 | + # - cron: 0 1 * * * |
| 6 | + |
| 7 | +name: "Update CUDA-Q SHA" |
| 8 | + |
| 9 | +jobs: |
| 10 | + update-sha: |
| 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 | + |
| 21 | + - name: Fetch the latest commit |
| 22 | + id: get_sha |
| 23 | + run: | |
| 24 | + SHA=$(curl -s "https://api.github.com/repos/NVIDIA/cuda-quantum/commits/main" | jq -r '.sha') |
| 25 | + echo "Latest SHA: $SHA" |
| 26 | + echo "sha=$SHA" >> $GITHUB_ENV |
| 27 | +
|
| 28 | + - name: Update custom config file |
| 29 | + run: | |
| 30 | + jq '.cudaq.ref = "${{ env.sha }}"' .cudaq_version > .cudaq_version.tmp |
| 31 | + mv .cudaq_version.tmp .cudaq_version |
| 32 | + echo "Updated SHA in .cudaq_version" |
| 33 | +
|
| 34 | + - name: Commit and push changes |
| 35 | + run: | |
| 36 | + git config --global user.email "[email protected]" |
| 37 | + git config --global user.name "GitHub Action" |
| 38 | + BRANCH_NAME="update-cudaq-sha-$(date +%s)" |
| 39 | + git checkout -b $BRANCH_NAME |
| 40 | + git add .cudaq_version |
| 41 | + git commit -m "Update dependency SHA to ${{ env.sha }}" |
| 42 | + git push origin $BRANCH_NAME |
| 43 | +
|
| 44 | + - name: Create Pull Request |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ github.token }} |
| 47 | + run: | |
| 48 | + gh pr create \ |
| 49 | + --title "Bump CUDA-Q commit" \ |
| 50 | + --body "Auto update to the latest CUDA-Q commit" \ |
| 51 | + --head "${BRANCH_NAME}" \ |
| 52 | + --base "main" |
0 commit comments