|
| 1 | +name: "Update Chart Version in Target Repository" |
| 2 | +description: "Checks out the target repository, updates the chart tag for the current service, and opens a PR" |
| 3 | + |
| 4 | +inputs: |
| 5 | + tag: |
| 6 | + description: "Chart tag (version) to set for this service" |
| 7 | + required: true |
| 8 | + paths: |
| 9 | + description: "One or more YAML paths to update" |
| 10 | + required: true |
| 11 | + chart: |
| 12 | + description: "Name of the chart to update in target repository" |
| 13 | + required: false |
| 14 | + default: ${{ github.event.repository.name }} |
| 15 | + environment: |
| 16 | + description: "Deployment environment" |
| 17 | + required: true |
| 18 | + github_token: |
| 19 | + description: "GitHub token with write access to the target repository" |
| 20 | + required: true |
| 21 | + repository: |
| 22 | + description: "Target repository" |
| 23 | + required: false |
| 24 | + default: "site-values" |
| 25 | + branch: |
| 26 | + description: "Target base branch in repository" |
| 27 | + required: false |
| 28 | + default: "master" |
| 29 | + pr_labels: |
| 30 | + description: "Labels to apply on the created PR" |
| 31 | + required: false |
| 32 | + assignees: |
| 33 | + description: "Comma-separated list of assignees to assign to the PR" |
| 34 | + required: false |
| 35 | + reviewers: |
| 36 | + description: "Comma-separated list of reviewers to request review from" |
| 37 | + required: false |
| 38 | + |
| 39 | +runs: |
| 40 | + using: "composite" |
| 41 | + steps: |
| 42 | + - name: Checkout ${{ inputs.repository }} repo |
| 43 | + uses: actions/checkout@v5 |
| 44 | + with: |
| 45 | + repository: MapColonies/${{ inputs.repository }} |
| 46 | + token: ${{ inputs.github_token }} |
| 47 | + path: ${{ inputs.repository }} |
| 48 | + ref: ${{ inputs.branch }} |
| 49 | + |
| 50 | + - name: Update tags in ${{ inputs.repository }} |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + set -euo pipefail |
| 54 | +
|
| 55 | + echo "Updating chartsVersions[\"${{ inputs.chart }}\"] to \"${{ inputs.tag }}\" in:" |
| 56 | + # Support newline or comma separated list |
| 57 | + echo '${{ inputs.paths }}' | tr ',' '\n' | while IFS= read -r relpath; do |
| 58 | + # skip empty lines |
| 59 | + [ -z "$relpath" ] && continue |
| 60 | +
|
| 61 | + # trim possible leading/trailing spaces |
| 62 | + relpath="$(echo "$relpath" | xargs)" |
| 63 | +
|
| 64 | + echo " - $relpath" |
| 65 | + yq eval -i \ |
| 66 | + ".chartsVersions[\"${{ inputs.chart }}\"] = \"${{ inputs.tag }}\"" \ |
| 67 | + "${{ inputs.repository }}/$relpath" |
| 68 | + done |
| 69 | +
|
| 70 | + - name: Compute PR title and commit message |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | +
|
| 75 | + prefix=$([ "${{ inputs.environment }}" = "prod" ] && echo "deps" || echo "devdeps") |
| 76 | + commit_msg="${prefix}(${{ inputs.environment }}): update ${{ inputs.chart }} to ${{ inputs.tag }}" |
| 77 | +
|
| 78 | + if [ "${{ inputs.environment }}" = "prod" ]; then |
| 79 | + title="deps: prod changes" |
| 80 | + else |
| 81 | + title="$commit_msg" |
| 82 | + fi |
| 83 | +
|
| 84 | + echo "PR_COMMIT_MESSAGE=$commit_msg" >> "$GITHUB_ENV" |
| 85 | + echo "PR_TITLE=$title" >> "$GITHUB_ENV" |
| 86 | +
|
| 87 | +
|
| 88 | + - name: Create Pull Request |
| 89 | + uses: peter-evans/create-pull-request@v7 |
| 90 | + with: |
| 91 | + path: ${{ inputs.repository }} |
| 92 | + token: ${{ inputs.github_token }} |
| 93 | + author: "mapcolonies[bot] <devops[bot]@mapcolonies.com>" |
| 94 | + committer: "mapcolonies[bot] <devops[bot]@mapcolonies.com>" |
| 95 | + assignees: ${{ inputs.assignees && inputs.assignees || '' }} |
| 96 | + reviewers: ${{ inputs.reviewers && inputs.reviewers || '' }} |
| 97 | + commit-message: ${{ env.PR_COMMIT_MESSAGE }} |
| 98 | + title: ${{ env.PR_TITLE }} |
| 99 | + body: | |
| 100 | + Trigger commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }} |
| 101 | +
|
| 102 | + Updated files: |
| 103 | + ${{ inputs.paths }} |
| 104 | + labels: ${{ inputs.pr_labels && inputs.pr_labels || '' }}, ${{ inputs.environment }}, ${{ inputs.environment == 'dev' && 'auto-merge' || '' }} |
| 105 | + branch: "${{ inputs.environment == 'prod' && 'prod' || |
| 106 | + format('{0}-{1}-{2}', inputs.environment, inputs.chart, github.sha) }}" |
| 107 | + base: ${{ inputs.branch }} |
0 commit comments