|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: Update Tika Docker Image Version |
| 17 | + |
| 18 | +on: |
| 19 | + schedule: |
| 20 | + - cron: '0 6 * * *' # daily at 06:00 UTC |
| 21 | + workflow_dispatch: |
| 22 | + inputs: |
| 23 | + tag: |
| 24 | + description: 'Tika Docker image tag (e.g. 3.3.0.0-full)' |
| 25 | + required: false |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + pull-requests: write |
| 30 | + |
| 31 | +jobs: |
| 32 | + update-tika-version: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v6 |
| 37 | + |
| 38 | + - name: Determine new tag |
| 39 | + id: new-tag |
| 40 | + run: | |
| 41 | + if [ -n "${{ github.event.inputs.tag }}" ]; then |
| 42 | + NEW_TAG="${{ github.event.inputs.tag }}" |
| 43 | + else |
| 44 | + NEW_TAG=$(curl -s "https://hub.docker.com/v2/repositories/apache/tika/tags?page_size=10&ordering=-last_updated" \ |
| 45 | + | jq -r '.results[].name' \ |
| 46 | + | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-full$' \ |
| 47 | + | sort -V \ |
| 48 | + | tail -1) |
| 49 | + fi |
| 50 | +
|
| 51 | + if [ -z "$NEW_TAG" ]; then |
| 52 | + echo "::error::Could not determine the latest Tika Docker image tag" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + echo "tag=$NEW_TAG" >> "$GITHUB_OUTPUT" |
| 57 | + shell: bash |
| 58 | + |
| 59 | + - name: Read current appVersion |
| 60 | + id: current |
| 61 | + run: | |
| 62 | + CURRENT=$(grep '^appVersion:' Chart.yaml | sed 's/appVersion: *"\(.*\)"/\1/') |
| 63 | + echo "tag=$CURRENT" >> "$GITHUB_OUTPUT" |
| 64 | + shell: bash |
| 65 | + |
| 66 | + - name: Compare versions |
| 67 | + id: compare |
| 68 | + run: | |
| 69 | + if [ "${{ steps.new-tag.outputs.tag }}" = "${{ steps.current.outputs.tag }}" ]; then |
| 70 | + echo "No update needed. Current version (${{ steps.current.outputs.tag }}) is already the latest." |
| 71 | + echo "updated=false" >> "$GITHUB_OUTPUT" |
| 72 | + else |
| 73 | + echo "Update available: ${{ steps.current.outputs.tag }} -> ${{ steps.new-tag.outputs.tag }}" |
| 74 | + echo "updated=true" >> "$GITHUB_OUTPUT" |
| 75 | + fi |
| 76 | + shell: bash |
| 77 | + |
| 78 | + - name: Derive chart version |
| 79 | + if: steps.compare.outputs.updated == 'true' |
| 80 | + id: chart-version |
| 81 | + run: | |
| 82 | + CHART_VERSION=$(echo "${{ steps.new-tag.outputs.tag }}" | sed 's/-full$//' | sed 's/\.[0-9]*$//') |
| 83 | + echo "version=$CHART_VERSION" >> "$GITHUB_OUTPUT" |
| 84 | + shell: bash |
| 85 | + |
| 86 | + - name: Update version files |
| 87 | + if: steps.compare.outputs.updated == 'true' |
| 88 | + run: | |
| 89 | + NEW_TAG="${{ steps.new-tag.outputs.tag }}" |
| 90 | + CHART_VERSION="${{ steps.chart-version.outputs.version }}" |
| 91 | + OLD_TAG="${{ steps.current.outputs.tag }}" |
| 92 | +
|
| 93 | + sed -i "s/^appVersion: \".*\"/appVersion: \"${NEW_TAG}\"/" Chart.yaml |
| 94 | + sed -i "s/^version: \".*\"/version: \"${CHART_VERSION}\"/" Chart.yaml |
| 95 | +
|
| 96 | + sed -i "s/tag: '.*'/tag: '${NEW_TAG}'/" values.yaml |
| 97 | +
|
| 98 | + sed -i "s/\"default\": \"${OLD_TAG}\"/\"default\": \"${NEW_TAG}\"/" values.schema.json |
| 99 | + shell: bash |
| 100 | + |
| 101 | + - name: Create Pull Request |
| 102 | + if: steps.compare.outputs.updated == 'true' |
| 103 | + uses: peter-evans/create-pull-request@v8 |
| 104 | + with: |
| 105 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + branch: auto-update/tika-${{ steps.new-tag.outputs.tag }} |
| 107 | + commit-message: "Bump Apache Tika Docker image to ${{ steps.new-tag.outputs.tag }}" |
| 108 | + title: "Bump Apache Tika Docker image to ${{ steps.new-tag.outputs.tag }}" |
| 109 | + body: | |
| 110 | + Automated version bump of the Apache Tika Docker image. |
| 111 | +
|
| 112 | + **Old version:** `${{ steps.current.outputs.tag }}` |
| 113 | + **New version:** `${{ steps.new-tag.outputs.tag }}` |
| 114 | + **Chart version:** `${{ steps.chart-version.outputs.version }}` |
| 115 | +
|
| 116 | + [View available tags on Docker Hub](https://hub.docker.com/r/apache/tika/tags) |
| 117 | + labels: | |
| 118 | + dependencies |
| 119 | + automated |
0 commit comments