|
| 1 | +name: Update requirements.cachito |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run Monday, Wednesday, Friday at 1 PM UTC |
| 6 | + - cron: '0 13 * * 1,3,5' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + force_update: |
| 10 | + description: 'Force update even if no changes detected' |
| 11 | + required: false |
| 12 | + default: false |
| 13 | + type: boolean |
| 14 | + target_branch: |
| 15 | + description: 'Target branch for the PR' |
| 16 | + required: false |
| 17 | + default: 'main' |
| 18 | + type: string |
| 19 | + |
| 20 | +env: |
| 21 | + # Repositories to track |
| 22 | + IRONIC_REPO: "openshift/openstack-ironic" |
| 23 | + SUSHY_REPO: "openshift/openstack-sushy" |
| 24 | + # Default branches to track |
| 25 | + IRONIC_BRANCH: "main" |
| 26 | + SUSHY_BRANCH: "main" |
| 27 | + |
| 28 | +jobs: |
| 29 | + update-requirements: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + container: |
| 32 | + image: quay.io/centos/centos:stream9 |
| 33 | + permissions: |
| 34 | + contents: write |
| 35 | + pull-requests: write |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Install dependencies |
| 39 | + run: | |
| 40 | + dnf upgrade -y |
| 41 | + dnf install -y git curl jq sed |
| 42 | +
|
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 45 | + with: |
| 46 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + fetch-depth: 0 |
| 48 | + |
| 49 | + - name: Set up Git |
| 50 | + run: | |
| 51 | + git config --global user.name "github-actions[bot]" |
| 52 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 53 | +
|
| 54 | + - name: Get latest commit hashes |
| 55 | + id: get-commits |
| 56 | + run: | |
| 57 | + # Get latest commit hash from ironic repository |
| 58 | + IRONIC_HASH=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 59 | + "https://api.github.com/repos/${{ env.IRONIC_REPO }}/commits/${{ env.IRONIC_BRANCH }}" | \ |
| 60 | + jq -r '.sha') |
| 61 | +
|
| 62 | + # Get latest commit hash from sushy repository |
| 63 | + SUSHY_HASH=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 64 | + "https://api.github.com/repos/${{ env.SUSHY_REPO }}/commits/${{ env.SUSHY_BRANCH }}" | \ |
| 65 | + jq -r '.sha') |
| 66 | +
|
| 67 | + echo "ironic_hash=$IRONIC_HASH" >> $GITHUB_OUTPUT |
| 68 | + echo "sushy_hash=$SUSHY_HASH" >> $GITHUB_OUTPUT |
| 69 | +
|
| 70 | + echo "Latest Ironic commit: $IRONIC_HASH" |
| 71 | + echo "Latest Sushy commit: $SUSHY_HASH" |
| 72 | +
|
| 73 | + - name: Check current hashes in requirements.cachito |
| 74 | + id: current-hashes |
| 75 | + run: | |
| 76 | + # Extract current hashes from requirements.cachito |
| 77 | + CURRENT_IRONIC=$(grep "ironic @ git+" requirements.cachito | sed 's/.*@//' || echo "") |
| 78 | + CURRENT_SUSHY=$(grep "sushy @ git+" requirements.cachito | sed 's/.*@//' || echo "") |
| 79 | +
|
| 80 | + echo "current_ironic=$CURRENT_IRONIC" >> $GITHUB_OUTPUT |
| 81 | + echo "current_sushy=$CURRENT_SUSHY" >> $GITHUB_OUTPUT |
| 82 | +
|
| 83 | + echo "Current Ironic hash: $CURRENT_IRONIC" |
| 84 | + echo "Current Sushy hash: $CURRENT_SUSHY" |
| 85 | +
|
| 86 | + - name: Check if update is needed |
| 87 | + id: check-update |
| 88 | + run: | |
| 89 | + NEED_UPDATE=false |
| 90 | +
|
| 91 | + if [ "${{ steps.get-commits.outputs.ironic_hash }}" != "${{ steps.current-hashes.outputs.current_ironic }}" ]; then |
| 92 | + echo "Ironic hash changed" |
| 93 | + NEED_UPDATE=true |
| 94 | + fi |
| 95 | +
|
| 96 | + if [ "${{ steps.get-commits.outputs.sushy_hash }}" != "${{ steps.current-hashes.outputs.current_sushy }}" ]; then |
| 97 | + echo "Sushy hash changed" |
| 98 | + NEED_UPDATE=true |
| 99 | + fi |
| 100 | +
|
| 101 | + if [ "${{ github.event.inputs.force_update }}" = "true" ]; then |
| 102 | + echo "Force update requested" |
| 103 | + NEED_UPDATE=true |
| 104 | + fi |
| 105 | +
|
| 106 | + echo "need_update=$NEED_UPDATE" >> $GITHUB_OUTPUT |
| 107 | +
|
| 108 | + - name: Update requirements.cachito |
| 109 | + if: steps.check-update.outputs.need_update == 'true' |
| 110 | + run: | |
| 111 | + # Create backup |
| 112 | + cp requirements.cachito requirements.cachito.bak |
| 113 | +
|
| 114 | + # Update the file |
| 115 | + sed -i "s|ironic @ git+https://github.com/${{ env.IRONIC_REPO }}@.*|ironic @ git+https://github.com/${{ env.IRONIC_REPO }}@${{ steps.get-commits.outputs.ironic_hash }}|" requirements.cachito |
| 116 | + sed -i "s|sushy @ git+https://github.com/${{ env.SUSHY_REPO }}@.*|sushy @ git+https://github.com/${{ env.SUSHY_REPO }}@${{ steps.get-commits.outputs.sushy_hash }}|" requirements.cachito |
| 117 | +
|
| 118 | + echo "Updated requirements.cachito:" |
| 119 | + cat requirements.cachito |
| 120 | +
|
| 121 | + - name: Get commit information |
| 122 | + if: steps.check-update.outputs.need_update == 'true' |
| 123 | + id: commit-info |
| 124 | + run: | |
| 125 | + # Get commit messages for the changelog |
| 126 | + IRONIC_MSG="" |
| 127 | + SUSHY_MSG="" |
| 128 | +
|
| 129 | + if [ "${{ steps.get-commits.outputs.ironic_hash }}" != "${{ steps.current-hashes.outputs.current_ironic }}" ]; then |
| 130 | + IRONIC_MSG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 131 | + "https://api.github.com/repos/${{ env.IRONIC_REPO }}/commits/${{ steps.get-commits.outputs.ironic_hash }}" | \ |
| 132 | + jq -r '.commit.message' | head -n1) |
| 133 | + fi |
| 134 | +
|
| 135 | + if [ "${{ steps.get-commits.outputs.sushy_hash }}" != "${{ steps.current-hashes.outputs.current_sushy }}" ]; then |
| 136 | + SUSHY_MSG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 137 | + "https://api.github.com/repos/${{ env.SUSHY_REPO }}/commits/${{ steps.get-commits.outputs.sushy_hash }}" | \ |
| 138 | + jq -r '.commit.message' | head -n1) |
| 139 | + fi |
| 140 | +
|
| 141 | + echo "ironic_msg=$IRONIC_MSG" >> $GITHUB_OUTPUT |
| 142 | + echo "sushy_msg=$SUSHY_MSG" >> $GITHUB_OUTPUT |
| 143 | +
|
| 144 | + - name: Create Pull Request |
| 145 | + if: steps.check-update.outputs.need_update == 'true' |
| 146 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 |
| 147 | + with: |
| 148 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + commit-message: | |
| 150 | + Update requirements.cachito with latest openshift forks commits |
| 151 | +
|
| 152 | + - Ironic: ${{ steps.get-commits.outputs.ironic_hash }} |
| 153 | + - Sushy: ${{ steps.get-commits.outputs.sushy_hash }} |
| 154 | + title: "chore: Update requirements.cachito with latest openshift forks commits" |
| 155 | + body: | |
| 156 | + ## Automated Requirements Update |
| 157 | +
|
| 158 | + This PR updates `requirements.cachito` with the latest commit hashes from openshift forks repositories. |
| 159 | +
|
| 160 | + ### Changes |
| 161 | +
|
| 162 | + #### Ironic (${{ env.IRONIC_REPO }}) |
| 163 | + - **Previous**: `${{ steps.current-hashes.outputs.current_ironic }}` |
| 164 | + - **New**: `${{ steps.get-commits.outputs.ironic_hash }}` |
| 165 | + - **Latest commit**: ${{ steps.commit-info.outputs.ironic_msg }} |
| 166 | + - **Compare**: https://github.com/${{ env.IRONIC_REPO }}/compare/${{ steps.current-hashes.outputs.current_ironic }}..${{ steps.get-commits.outputs.ironic_hash }} |
| 167 | +
|
| 168 | + #### Sushy (${{ env.SUSHY_REPO }}) |
| 169 | + - **Previous**: `${{ steps.current-hashes.outputs.current_sushy }}` |
| 170 | + - **New**: `${{ steps.get-commits.outputs.sushy_hash }}` |
| 171 | + - **Latest commit**: ${{ steps.commit-info.outputs.sushy_msg }} |
| 172 | + - **Compare**: https://github.com/${{ env.SUSHY_REPO }}/compare/${{ steps.current-hashes.outputs.current_sushy }}..${{ steps.get-commits.outputs.sushy_hash }} |
| 173 | +
|
| 174 | + ### Verification |
| 175 | +
|
| 176 | + Before merging, please ensure: |
| 177 | + - The new commits don't introduce breaking changes |
| 178 | + - The build completes successfully |
| 179 | + - All tests pass |
| 180 | +
|
| 181 | + --- |
| 182 | + *This PR was automatically created by the update-requirements workflow.* |
| 183 | + branch: update-requirements-cachito |
| 184 | + base: ${{ github.event.inputs.target_branch || 'main' }} |
| 185 | + delete-branch: true |
| 186 | + draft: false |
| 187 | + labels: | |
| 188 | + automated |
| 189 | + dependencies |
| 190 | + cachito |
| 191 | +
|
| 192 | + - name: Summary |
| 193 | + run: | |
| 194 | + if [ "${{ steps.check-update.outputs.need_update }}" = "true" ]; then |
| 195 | + echo "Requirements updated and PR created" |
| 196 | + echo "- Ironic: ${{ steps.get-commits.outputs.ironic_hash }}" |
| 197 | + echo "- Sushy: ${{ steps.get-commits.outputs.sushy_hash }}" |
| 198 | + else |
| 199 | + echo "No updates needed - all hashes are current" |
| 200 | + fi |
0 commit comments