-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
104 lines (92 loc) · 3.81 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
93
94
95
96
97
98
99
100
101
102
103
104
name: 'Remote Config Release Registration'
description: 'Registering a new release in remote-config'
inputs:
package-id:
description: 'provisioning package id in artifacts'
required: true
application-name:
description: 'name of application which is being released. should be alphanumeric'
required: true
create-pr:
description: 'if set true, this action tries to create pr in application-live and you should set all optional input parameters'
required: true
user-email:
description: 'user email for the commiting github user'
required: false
user-name:
description: 'username for the commiting github user'
required: false
organization-name:
description: 'organization name'
required: false
repository-name:
description: 'repository name'
required: false
API_TOKEN_GITHUB:
description: 'github api token with full-repo access'
required: false
runs:
using: "composite"
steps:
# - name: "Checkout the repository"
# uses: actions/checkout@v2
- name: "Get provisioning package"
uses: actions/download-artifact@v3
with:
name: ${{ inputs.package-id }}
path: ./tmp
- name: Get Timestamp
id: time
uses: nanzm/[email protected]
with:
format: 'YYYYMMDDHHmm'
- name: "Update basic-installation & create PR"
if: ${{ inputs.create-pr == 'true' }}
env:
USER_EMAIL: ${{ inputs.user-email }}
USER_NAME: ${{ inputs.user-name }}
GH_TOKEN: ${{ inputs.API_TOKEN_GITHUB }}
IMAGE_TAG_NAME: remote-config-v-${{ github.run_number }}-${{ steps.time.outputs.time }}
DESTINATION_REPOSITORY_USERNAME: ${{ inputs.organization-name }}
DESTINATION_REPOSITORY_NAME: ${{ inputs.repository-name }}
run: |
GIT_CMD_REPOSITORY="https://[email protected]/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git"
TARGET_BRANCH=new-release-"$RANDOM"
TMP_DIR=$(mktemp -d)
echo "[+] Git version"
git --version
echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME"
git config --global user.email "$USER_EMAIL"
git config --global user.name "$USER_NAME"
{
git clone "$GIT_CMD_REPOSITORY" $TMP_DIR
} || {
echo "::error::Could not clone the destination repository. Command:"
echo "::error::git clone --single-branch --branch main $GIT_CMD_REPOSITORY $TMP_DIR"
echo "::error::(Note that if they exist USER_NAME and API_TOKEN is redacted by GitHub)"
echo "::error::Please verify that the target repository exist AND that it contains the destination branch name, and is accesible by the API_TOKEN_GITHUB"
exit 1
}
ls -la $TMP_DIR
cd $TMP_DIR
echo "[+] Creating local branch"
git checkout -b "$TARGET_BRANCH"
echo "[+] Updating tag version in basic-installation file"
sed -i "/&releaseProvisioningPackageVersion/c\releaseProvisioningPackageVersion: &releaseProvisioningPackageVersion $IMAGE_TAG_NAME" runtimes/dev/basic-installation.yaml
echo "[+] Adding git commit"
git add .
if git status | grep -q "Changes to be committed"
then
echo "[+] Commiting to local"
git commit --message "Add new release version $IMAGE_TAG_NAME"
echo "[+] Pushing git commit"
git push -u origin HEAD:"$TARGET_BRANCH"
echo "[+] Creating a pull request"
gh pr create -t "[autogenerated] add new release to $IMAGE_TAG_NAME" \
-b "Add new release version to remote-config. This is autogenerated by release-registration pipeline" \
-B main \
-H $TARGET_BRANCH
else
echo "::error::No changes detected"
fi
shell: bash