|
| 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: Update Istio in Dockerfile |
| 65 | + if: steps.compare-istio.outputs.needs_update == 'true' |
| 66 | + run: | |
| 67 | + LATEST="${{ steps.latest-istio.outputs.version }}" |
| 68 | +
|
| 69 | + # Ensure the expected ENV ISTIO_VERSION line exists before attempting to update |
| 70 | + if ! grep -q '^ENV ISTIO_VERSION=' linux/base.Dockerfile; then |
| 71 | + echo "Error: Could not find 'ENV ISTIO_VERSION=' line in linux/base.Dockerfile" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + sed -i "s/^ENV ISTIO_VERSION=.*/ENV ISTIO_VERSION=${LATEST}/" linux/base.Dockerfile |
| 76 | +
|
| 77 | + # Verify that the update was applied successfully |
| 78 | + if ! grep -q "^ENV ISTIO_VERSION=${LATEST}$" linux/base.Dockerfile; then |
| 79 | + echo "Error: Failed to update ISTIO_VERSION to ${LATEST} in linux/base.Dockerfile" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | + echo "Updated ISTIO_VERSION to ${LATEST}" |
| 83 | +
|
| 84 | + - name: Create Pull Request |
| 85 | + if: steps.compare-istio.outputs.needs_update == 'true' |
| 86 | + uses: peter-evans/create-pull-request@v6 |
| 87 | + with: |
| 88 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + commit-message: "chore: update pinned library versions" |
| 90 | + title: "chore: update pinned library versions" |
| 91 | + body: | |
| 92 | + ## Automated Library Version Updates |
| 93 | + |
| 94 | + This PR updates the following pinned library versions: |
| 95 | + |
| 96 | + ${{ steps.compare-istio.outputs.needs_update == 'true' && format('- **Istio**: `{0}` → `{1}`', steps.current-istio.outputs.version, steps.latest-istio.outputs.version) || '' }} |
| 97 | + |
| 98 | + ### Changes |
| 99 | + - Updated version variables in [linux/base.Dockerfile](linux/base.Dockerfile) |
| 100 | + |
| 101 | + ### Release Notes |
| 102 | + ${{ steps.compare-istio.outputs.needs_update == 'true' && format('- [Istio {0}](https://github.com/istio/istio/releases/tag/{0})', steps.latest-istio.outputs.version) || '' }} |
| 103 | + |
| 104 | + --- |
| 105 | + *This PR was automatically created by the Update Pinned Library Versions workflow.* |
| 106 | + branch: update-pinned-libs-${{ github.run_number }} |
| 107 | + delete-branch: true |
| 108 | + labels: | |
| 109 | + dependencies |
| 110 | + automated |
0 commit comments