forked from DataDog/sync-upstream-release-tag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
92 lines (88 loc) · 3.11 KB
/
action.yml
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
<!--
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
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- 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=$(gh release list -R ${{ inputs.upstream_repo }} --exclude-drafts --exclude-pre-releases -L 10 | grep -Eo "\bv[0-9]+\.[0-9]+\.[0-9]+\b" | sort -V | tail -n1) >> $GITHUB_OUTPUT
- name: Fetch last base
shell: bash
run: git fetch origin tag ${{ inputs.base_tag }}
- name: Fetch datadog branch
shell: bash
run: git fetch origin ${{ inputs.datadog_branch }}
- name: Checkout datadog branch
shell: bash
run: git checkout ${{ inputs.datadog_branch }}
- name: Rebase datadog branch
shell: bash
run: git rebase --onto ${{ steps.get_latest_tag.outputs.tag }} ${{ inputs.base_tag }}
- name: Push datadog branch
shell: bash
run: git push -f origin ${{ inputs.datadog_branch }}
- name: Tag release
shell: bash
run: git tag -f ${{ steps.get_latest_tag.outputs.tag }}-dd ${{ inputs.datadog_branch }}
- name: Push tag
shell: bash
run: git push -f origin ${{ steps.get_latest_tag.outputs.tag }}-dd
- name: Move last base tag
shell: bash
run: git tag -f ${{ inputs.base_tag }} ${{ steps.get_latest_tag.outputs.tag }}
- name: Push last base tag
shell: bash
run: git push -f origin ${{ steps.get_latest_tag.outputs.tag }}-dd
branding:
icon: 'package'
color: 'purple'