-
Notifications
You must be signed in to change notification settings - Fork 173
109 lines (97 loc) · 5.55 KB
/
update_docker_images.yaml
File metadata and controls
109 lines (97 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Update Docker Images
# Description: This workflow automatically checks for new versions of specified Docker images and
# updates them if necessary.
on:
schedule:
# Run every 12th hour at minute 45 past.
- cron: "45 */12 * * *"
workflow_dispatch:
inputs:
DEBUG_MODE:
description: 'Enable debug mode'
required: false
default: 'false'
permissions:
contents: write
pull-requests: write
jobs:
check_and_update:
runs-on: ubuntu-latest
strategy:
fail-fast: false # Continue all jobs even if one fails
matrix:
# Docker images to check for version updates
include:
- name: 'java'
component: 'operator'
yaml_file_path: 'helm-charts/splunk-otel-collector/values.yaml'
yaml_value_path: '.instrumentation.spec.java.image'
filter: 'v2.'
- name: 'nodejs'
component: 'operator'
yaml_file_path: 'helm-charts/splunk-otel-collector/values.yaml'
yaml_value_path: '.instrumentation.spec.nodejs.image'
- name: 'dotnet'
component: 'operator'
yaml_file_path: 'helm-charts/splunk-otel-collector/values.yaml'
yaml_value_path: '.instrumentation.spec.dotnet.image'
# TODO: Add support for Splunk image
# - name: 'splunk'
# yaml_file_path: 'ci_scripts/k8s-splunk.yml'
# yaml_value_path: 'select(.kind == \\\"Pod\\\").spec.containers[] | select(.name == \\\"splunk\\\")'
env:
DEBUG_MODE: ${{ github.event.inputs.DEBUG_MODE }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Set up Helm
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 #v4
with:
version: v4.1.4
- name: Check for Version Updates
id: check_for_update
run: |
echo "Checking docker image version for ${{ matrix.name }}"
make update-docker-image FILE_PATH=${{ matrix.yaml_file_path }} QUERY_STRING='${{ matrix.yaml_value_path }}' FILTER='${{ matrix.filter }}' DEBUG_MODE="$DEBUG_MODE"
- name: Check if PR is already open
id: check_if_pr_open
run: |
DIFF=1
git fetch origin
( (git show-ref --verify --quiet refs/heads/update-${{ matrix.name }}) || (git diff --no-ext-diff --quiet main..update-${{ matrix.name }} -- helm-charts) ) && DIFF=0
echo "PR_NEEDED=$DIFF" >> "$GITHUB_OUTPUT"
- name: Open PR for Version Update
id: open_pr
if: ${{ steps.check_for_update.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 }}
uses: ./.github/actions/create-pr
with:
branch: update-${{ matrix.name }}
commit-message: Update ${{ matrix.name }} instrumentation version
title: Bump ${{ matrix.name }} from ${{ steps.check_for_update.outputs.CURRENT_TAG }} to ${{ steps.check_for_update.outputs.LATEST_TAG }} in ${{ matrix.yaml_file_path }}
body: Use the latest version of ${{ matrix.name }}
author-name: ${{ github.event_name == 'schedule' && 'github-actions[bot]' || github.actor }}
author-email: ${{ github.event_name == 'schedule' && '41898282+github-actions[bot]@users.noreply.github.com' || format('{1}+{0}@users.noreply.github.com', github.actor, github.actor_id) }}
- name: Apply Version Update and Generate Changelog
if: ${{ steps.check_for_update.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 && steps.open_pr.outputs.pull-request-number != '' }}
run: |
# Apply the version update, update the rendered examples with the version update, and create a changelog entry
# Re-run the update before rendering/changelog generation to keep derived files in sync.
make update-docker-image FILE_PATH=${{ matrix.yaml_file_path }} QUERY_STRING='${{ matrix.yaml_value_path }}' FILTER='${{ matrix.filter }}' DEBUG_MODE="$DEBUG_MODE"
make render
make chlog-new FILENAME="update-${{ matrix.name }}" CHANGE_TYPE=enhancement COMPONENT=${{ matrix.component }} NOTE="Bump ${{ matrix.name }} to ${{ steps.check_for_update.outputs.LATEST_TAG }} in ${{ matrix.yaml_file_path }}" ISSUES="[${{ steps.open_pr.outputs.pull-request-number }}]"
- name: Run pre-commit to fix formatting
if: ${{ steps.check_for_update.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 && steps.open_pr.outputs.pull-request-number != '' }}
run: |
pip install pre-commit==4.5.1
pre-commit run --all-files || true
env:
SKIP: actionlint,render,go-fmt,go-lint,go-mod-tidy
- name: Finalize PR with updates
if: ${{ steps.check_for_update.outputs.NEED_UPDATE == 1 && steps.check_if_pr_open.outputs.PR_NEEDED == 1 && steps.open_pr.outputs.pull-request-number != '' }}
uses: ./.github/actions/create-pr
with:
branch: update-${{ matrix.name }}
commit-message: Update ${{ matrix.name }} instrumentation version
title: Bump ${{ matrix.name }} from ${{ steps.check_for_update.outputs.CURRENT_TAG }} to ${{ steps.check_for_update.outputs.LATEST_TAG }} in ${{ matrix.yaml_file_path }}
body: Use the latest version of ${{ matrix.name }}
author-name: ${{ github.event_name == 'schedule' && 'github-actions[bot]' || github.actor }}
author-email: ${{ github.event_name == 'schedule' && '41898282+github-actions[bot]@users.noreply.github.com' || format('{1}+{0}@users.noreply.github.com', github.actor, github.actor_id) }}