This repository was archived by the owner on Apr 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
160 lines (153 loc) · 5.51 KB
/
Copy pathaction.yml
File metadata and controls
160 lines (153 loc) · 5.51 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache License 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2023 Datadog, Inc.
name: GitHub Sync Upstream Release
description: Get latest upstream release, rebase on top and push the dd release tag
author: antoine.gaillard@datadoghq.com
inputs:
github_actor:
description: Github actor
required: true
github_repository:
description: Github repository
required: true
github_token:
description: Github token
required: true
upstream_repo:
description: Upstream repo
required: true
datadog_branch:
description: Branch name that contains our patches
required: false
default: datadog
base_tag:
description: Tag used to mark the base
required: false
default: last-dd-base
date_suffix:
description: Date format to append as suffix to the tag
required: false
default: "%Y%V"
major_version:
description: >
Major version regex
Used in the default version tags regex. Use inputs.version_regex
if you want more control over the whole pattern.
required: false
default: "[0-9]+"
minor_version:
description: >
Minor version regex
Used in the default version tags regex. Use inputs.version_regex
if you want more control over the whole pattern.
required: false
default: "[0-9]+"
version_regex:
description: >
Regex used to match release version tags.
Backslash characters need to be escaped.
Use this if the default regex provided by this action in combination
with inputs.major_version and inputs.minor_version is not enough.
required: false
default: ""
runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
token: ${{ inputs.github_token }}
- name: Craft version tags regex pattern
id: set_version_regex
shell: bash
run: |
# test whether a version_regex was passed in inputs
if [[ "${{ inputs.version_regex }}" ]]
then
echo regex="${{ inputs.version_regex }}" >> $GITHUB_OUTPUT
else
# This default regex matches semver tags with an optional 'v' prefix.
echo regex="^(v)?${{ inputs.major_version }}\.${{ inputs.minor_version }}\.[0-9]+$" >> $GITHUB_OUTPUT
fi
- name: Setup git config
shell: bash
env:
GITHUB_ACTOR: ${{ inputs.github_actor }}
GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --local user.password ${GITHUB_TOKEN}
- name: Setup remotes
shell: bash
env:
GITHUB_ACTOR: ${{ inputs.github_actor }}
GITHUB_TOKEN: ${{ inputs.github_token }}
run: |
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git remote add upstream https://github.com/${{ inputs.upstream_repo }}
- name: Fetch upstream tags
shell: bash
run: git fetch upstream --tags
- name: Get latest tag
id: get_latest_tag
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
run: echo tag=$(git tag -l | grep -E "${{ steps.set_version_regex.outputs.regex }}" | sort -V | tail -n1) >> $GITHUB_OUTPUT
- name: Get dd tag
id: get_dd_tag
shell: bash
run: |
DATE_SUFFIX=${{ inputs.date_suffix }}
if [ -n "$DATE_SUFFIX" ]; then
DATE_SUFFIX=".$(date +$DATE_SUFFIX)"
fi
echo "tag=${{ steps.get_latest_tag.outputs.tag }}-dd$DATE_SUFFIX" >> $GITHUB_OUTPUT
- name: Check if dd tag already exists
id: check_dd_tag
shell: bash
run: git fetch origin tag ${{ steps.get_dd_tag.outputs.tag }}
continue-on-error: true
- name: Exit if dd_tag already exists
if: steps.check_dd_tag.outcome == 'success'
shell: bash
run: echo "Tag already exists, nothing to do"
- name: Fetch last base
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git fetch origin tag ${{ inputs.base_tag }}
- name: Fetch datadog branch
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git fetch origin ${{ inputs.datadog_branch }}
- name: Checkout datadog branch
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git checkout ${{ inputs.datadog_branch }}
- name: Rebase datadog branch
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git rebase --onto ${{ steps.get_latest_tag.outputs.tag }} ${{ inputs.base_tag }}
- name: Push datadog branch
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git push -f origin ${{ inputs.datadog_branch }}
- name: Tag release
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git tag -f ${{ steps.get_dd_tag.outputs.tag }} ${{ inputs.datadog_branch }}
- name: Push tag
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git push -f origin ${{ steps.get_dd_tag.outputs.tag }}
- name: Move last base tag
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git tag -f ${{ inputs.base_tag }} ${{ steps.get_latest_tag.outputs.tag }}
- name: Push last base tag
if: steps.check_dd_tag.outcome == 'failure'
shell: bash
run: git push -f origin ${{ inputs.base_tag }}
branding:
icon: 'package'
color: 'purple'