|
| 1 | +name: Update Pinned Library Versions |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Check for updates every 2 weeks (1st and 15th of each month) at 6:00 AM UTC |
| 6 | + - cron: '0 6 1,15 * *' |
| 7 | + workflow_dispatch: # Allow manual trigger |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-library-versions: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Get current Istio version |
| 23 | + id: current-istio |
| 24 | + run: | |
| 25 | + CURRENT_VERSION=$(grep 'ENV ISTIO_VERSION=' linux/base.Dockerfile | cut -d'=' -f2) |
| 26 | + if [ -z "${CURRENT_VERSION}" ]; then |
| 27 | + echo "Error: Unable to determine current Istio version from linux/base.Dockerfile" >&2 |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT |
| 31 | + echo "Current Istio version: ${CURRENT_VERSION}" |
| 32 | +
|
| 33 | + - name: Get latest Istio version |
| 34 | + id: latest-istio |
| 35 | + run: | |
| 36 | + set -e |
| 37 | + LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/istio/istio/releases/latest | jq -er '.tag_name') || { |
| 38 | + echo "Error: Failed to fetch latest Istio release information from GitHub API." >&2 |
| 39 | + exit 1 |
| 40 | + } |
| 41 | + |
| 42 | + if [ -z "${LATEST_VERSION}" ] || [ "${LATEST_VERSION}" = "null" ]; then |
| 43 | + echo "Error: Received empty or invalid latest Istio version from GitHub API." >&2 |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + |
| 47 | + echo "version=${LATEST_VERSION}" >> $GITHUB_OUTPUT |
| 48 | + echo "Latest Istio version: ${LATEST_VERSION}" |
| 49 | +
|
| 50 | + - name: Compare Istio versions |
| 51 | + id: compare-istio |
| 52 | + run: | |
| 53 | + CURRENT="${{ steps.current-istio.outputs.version }}" |
| 54 | + LATEST="${{ steps.latest-istio.outputs.version }}" |
| 55 | + |
| 56 | + if [ "${CURRENT}" != "${LATEST}" ]; then |
| 57 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 58 | + echo "Istio update needed: ${CURRENT} -> ${LATEST}" |
| 59 | + else |
| 60 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 61 | + echo "Istio already on latest version: ${CURRENT}" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Get current RootlessKit version |
| 65 | + id: current-rootlesskit |
| 66 | + run: | |
| 67 | + CURRENT_VERSION=$(grep 'ROOTLESSKIT_VERSION=' linux/base.Dockerfile | grep -o 'v[0-9.]*') |
| 68 | + if [ -z "${CURRENT_VERSION}" ]; then |
| 69 | + echo "Error: Unable to determine current RootlessKit version from linux/base.Dockerfile" >&2 |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT |
| 73 | + echo "Current RootlessKit version: ${CURRENT_VERSION}" |
| 74 | +
|
| 75 | + - name: Get latest RootlessKit version |
| 76 | + id: latest-rootlesskit |
| 77 | + run: | |
| 78 | + set -e |
| 79 | + LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/rootless-containers/rootlesskit/releases/latest | jq -er '.tag_name') || { |
| 80 | + echo "Error: Failed to fetch latest RootlessKit release information from GitHub API." >&2 |
| 81 | + exit 1 |
| 82 | + } |
| 83 | + |
| 84 | + if [ -z "${LATEST_VERSION}" ] || [ "${LATEST_VERSION}" = "null" ]; then |
| 85 | + echo "Error: Received empty or invalid latest RootlessKit version from GitHub API." >&2 |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | + |
| 89 | + echo "version=${LATEST_VERSION}" >> $GITHUB_OUTPUT |
| 90 | + echo "Latest RootlessKit version: ${LATEST_VERSION}" |
| 91 | +
|
| 92 | + - name: Compare RootlessKit versions |
| 93 | + id: compare-rootlesskit |
| 94 | + run: | |
| 95 | + CURRENT="${{ steps.current-rootlesskit.outputs.version }}" |
| 96 | + LATEST="${{ steps.latest-rootlesskit.outputs.version }}" |
| 97 | + |
| 98 | + if [ "${CURRENT}" != "${LATEST}" ]; then |
| 99 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 100 | + echo "RootlessKit update needed: ${CURRENT} -> ${LATEST}" |
| 101 | + else |
| 102 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 103 | + echo "RootlessKit already on latest version: ${CURRENT}" |
| 104 | + fi |
| 105 | +
|
| 106 | + - name: Update Istio in Dockerfile |
| 107 | + if: steps.compare-istio.outputs.needs_update == 'true' |
| 108 | + run: | |
| 109 | + LATEST="${{ steps.latest-istio.outputs.version }}" |
| 110 | +
|
| 111 | + # Ensure the expected ENV ISTIO_VERSION line exists before attempting to update |
| 112 | + if ! grep -q '^ENV ISTIO_VERSION=' linux/base.Dockerfile; then |
| 113 | + echo "Error: Could not find 'ENV ISTIO_VERSION=' line in linux/base.Dockerfile" |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | +
|
| 117 | + sed -i "s/^ENV ISTIO_VERSION=.*/ENV ISTIO_VERSION=${LATEST}/" linux/base.Dockerfile |
| 118 | +
|
| 119 | + # Verify that the update was applied successfully |
| 120 | + if ! grep -q "^ENV ISTIO_VERSION=${LATEST}$" linux/base.Dockerfile; then |
| 121 | + echo "Error: Failed to update ISTIO_VERSION to ${LATEST} in linux/base.Dockerfile" |
| 122 | + exit 1 |
| 123 | + fi |
| 124 | + echo "Updated ISTIO_VERSION to ${LATEST}" |
| 125 | +
|
| 126 | + - name: Update RootlessKit in Dockerfile |
| 127 | + if: steps.compare-rootlesskit.outputs.needs_update == 'true' |
| 128 | + run: | |
| 129 | + LATEST="${{ steps.latest-rootlesskit.outputs.version }}" |
| 130 | +
|
| 131 | + if ! grep -q 'ROOTLESSKIT_VERSION=' linux/base.Dockerfile; then |
| 132 | + echo "Error: Could not find 'ROOTLESSKIT_VERSION=' line in linux/base.Dockerfile" |
| 133 | + exit 1 |
| 134 | + fi |
| 135 | +
|
| 136 | + sed -i "s/ROOTLESSKIT_VERSION=v[0-9.]*/ROOTLESSKIT_VERSION=${LATEST}/" linux/base.Dockerfile |
| 137 | +
|
| 138 | + if ! grep -q "ROOTLESSKIT_VERSION=${LATEST}" linux/base.Dockerfile; then |
| 139 | + echo "Error: Failed to update ROOTLESSKIT_VERSION to ${LATEST} in linux/base.Dockerfile" |
| 140 | + exit 1 |
| 141 | + fi |
| 142 | + echo "Updated ROOTLESSKIT_VERSION to ${LATEST}" |
| 143 | +
|
| 144 | + - name: Create and push branch with updates |
| 145 | + if: steps.compare-istio.outputs.needs_update == 'true' || steps.compare-rootlesskit.outputs.needs_update == 'true' |
| 146 | + run: | |
| 147 | + BRANCH_NAME="update-pinned-libs-$(date +%Y%m%d)" |
| 148 | + git config user.name "github-actions[bot]" |
| 149 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 150 | + git checkout -b "$BRANCH_NAME" |
| 151 | + git add linux/base.Dockerfile |
| 152 | + git commit -m "Upkeep: Update pinned library versions" |
| 153 | + git push origin "$BRANCH_NAME" |
| 154 | + echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 155 | + id: push-branch |
| 156 | + |
| 157 | + - name: Create Pull Request |
| 158 | + if: steps.compare-istio.outputs.needs_update == 'true' || steps.compare-rootlesskit.outputs.needs_update == 'true' |
| 159 | + env: |
| 160 | + GH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
| 161 | + run: | |
| 162 | + CURRENT_ISTIO="${{ steps.current-istio.outputs.version }}" |
| 163 | + LATEST_ISTIO="${{ steps.latest-istio.outputs.version }}" |
| 164 | + CURRENT_ROOTLESSKIT="${{ steps.current-rootlesskit.outputs.version }}" |
| 165 | + LATEST_ROOTLESSKIT="${{ steps.latest-rootlesskit.outputs.version }}" |
| 166 | + BRANCH_NAME="${{ steps.push-branch.outputs.branch }}" |
| 167 | + |
| 168 | + UPDATES="" |
| 169 | + RELEASE_NOTES="" |
| 170 | + |
| 171 | + if [ "${{ steps.compare-istio.outputs.needs_update }}" == "true" ]; then |
| 172 | + UPDATES="${UPDATES}- **Istio**: ${CURRENT_ISTIO} to ${LATEST_ISTIO}\n" |
| 173 | + RELEASE_NOTES="${RELEASE_NOTES}- Istio ${LATEST_ISTIO}: https://github.com/istio/istio/releases/tag/${LATEST_ISTIO}\n" |
| 174 | + fi |
| 175 | + |
| 176 | + if [ "${{ steps.compare-rootlesskit.outputs.needs_update }}" == "true" ]; then |
| 177 | + UPDATES="${UPDATES}- **RootlessKit**: ${CURRENT_ROOTLESSKIT} to ${LATEST_ROOTLESSKIT}\n" |
| 178 | + RELEASE_NOTES="${RELEASE_NOTES}- RootlessKit ${LATEST_ROOTLESSKIT}: https://github.com/rootless-containers/rootlesskit/releases/tag/${LATEST_ROOTLESSKIT}\n" |
| 179 | + fi |
| 180 | + |
| 181 | + gh pr create \ |
| 182 | + --title "chore: update pinned library versions" \ |
| 183 | + --body "## Automated Library Version Updates |
| 184 | + |
| 185 | + This PR updates the following pinned library versions: |
| 186 | + |
| 187 | + ${UPDATES} |
| 188 | + ### Changes |
| 189 | + - Updated version variables in linux/base.Dockerfile |
| 190 | + |
| 191 | + ### Release Notes |
| 192 | + ${RELEASE_NOTES} |
| 193 | + --- |
| 194 | + This PR was automatically created by the Update Pinned Library Versions workflow." \ |
| 195 | + --base master \ |
| 196 | + --head "${BRANCH_NAME}" \ |
| 197 | + --label "version_upgrade,automated_pr" |
0 commit comments