-
Notifications
You must be signed in to change notification settings - Fork 23
90 lines (81 loc) · 3.17 KB
/
update.yml
File metadata and controls
90 lines (81 loc) · 3.17 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
on:
workflow_dispatch:
inputs:
tag:
description: 'Flipt release tag (e.g., v1.60.0, v2.1.0). If not provided, will fetch latest release.'
required: false
type: string
permissions:
contents: write
pull-requests: write
name: Update Chart Versions
jobs:
update-chart-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install node
uses: actions/setup-node@v6.4.0
with:
node-version: "18"
- name: Fetch or Use Flipt Release Tag
id: fetch_tag
env:
GH_TOKEN: ${{ github.token }}
run: |
# Use provided tag or fetch latest release
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
TAG="${{ github.event.inputs.tag }}"
echo "Using provided tag: ${TAG}"
else
TAG=$(gh release view -R flipt-io/flipt --json tagName | jq -r .tagName)
echo "Fetched latest release tag: ${TAG}"
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
# Determine chart type based on tag prefix
if [[ $TAG == v2* ]]; then
echo "chart_name=flipt-v2" >> $GITHUB_OUTPUT
echo "chart_path=charts/flipt-v2" >> $GITHUB_OUTPUT
echo "chart_type=v2" >> $GITHUB_OUTPUT
else
echo "chart_name=flipt" >> $GITHUB_OUTPUT
echo "chart_path=charts/flipt" >> $GITHUB_OUTPUT
echo "chart_type=v1" >> $GITHUB_OUTPUT
fi
- name: Update Chart Versions
id: update_chart
run: |
TAG="${{ steps.fetch_tag.outputs.tag }}"
CHART_PATH="${{ steps.fetch_tag.outputs.chart_path }}"
pushd scripts/bumpVersion
npm install
npm run bump "../../${CHART_PATH}/Chart.yaml" "${TAG}"
popd
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.FLIPT_RELEASE_BOT_APP_ID }}
private_key: ${{ secrets.FLIPT_RELEASE_BOT_APP_PEM }}
installation_id: ${{ secrets.FLIPT_RELEASE_BOT_INSTALLATION_ID }}
- name: Open PR
env:
GIT_AUTHOR_NAME: flipt-bot
GIT_AUTHOR_EMAIL: dev@flipt.io
GIT_COMMITTER_NAME: flipt-bot
GIT_COMMITTER_EMAIL: dev@flipt.io
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
TAG="${{ steps.fetch_tag.outputs.tag }}"
CHART_PATH="${{ steps.fetch_tag.outputs.chart_path }}"
CHART_NAME="${{ steps.fetch_tag.outputs.chart_name }}"
CHART_TYPE="${{ steps.fetch_tag.outputs.chart_type }}"
BRANCH_NAME="update/${CHART_TYPE}/${TAG}-$(date +%s)"
git checkout -b "${BRANCH_NAME}"
git add "${CHART_PATH}/Chart.yaml"
git commit -m "feat: update Flipt ${CHART_TYPE} chart to release ${TAG}"
git push origin "${BRANCH_NAME}"
gh pr create --title "feat: update Flipt ${CHART_TYPE} chart to release ${TAG}" \
--head "${BRANCH_NAME}" \
--body "Updating ${CHART_NAME} chart to Flipt release [${TAG}](https://github.com/flipt-io/flipt/releases/tag/${TAG})."