-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
79 lines (71 loc) · 2.63 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
# This is a workflow to import configurations to IBM Cloud App Configuration service
name: IBM Cloud App Configuration Sync
author: Josephine Eskaline Joyce
description: workflow to import configurations to IBM Cloud App Configuration service
inputs:
IBM_CLOUD_API_KEY:
description: 'IBM Cloud API Key'
required: true
default: 'apikey'
IBM_CLOUD_REGION:
description: 'IBM Cloud region'
required: true
default: 'us-south'
IBM_CLOUD_RESOURCE_GROUP:
description: 'IBM Cloud Resouce group'
required: true
default: 'default'
AC_INSTANCE_ID:
description: 'IBM Cloud App Configuration instance id'
required: true
default: 'guid'
CONFIG_FILE_NAME:
description: 'JSON File containing the configurations'
required: true
default: 'appconfig.json'
GITHUB_REPO:
description: 'Repo name'
required: true
default: '${{ github.repository }}'
GITHUB_PULL_NUMBER:
description: 'Commit number of the pull request'
required: true
default: '${{ github.event.pull_request.number }}'
# Controls when the workflow will run
on:
# Triggers the workflow on pull request are approved
pull_request:
branches: [ main ]
types: [ closed ]
runs:
using: "composite"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Verify if the configuration file is updated
- name: Check file change
id: fileChangeMonitor
shell: bash
run: |
configurationUpdated=false
URL="https://api.github.com/repos/${{ inputs.GITHUB_REPO }}/pulls/${{ inputs.GITHUB_PULL_NUMBER }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | .filename')
echo $FILES
if echo $FILES | grep -q "${{ inputs.CONFIG_FILE_NAME }}"; then
configurationUpdated=true
echo "Configuration file is updated. "
fi
if [ "$configurationUpdated" == "true" ]
then
#Install IBM Cloud CLI
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install app-configuration
#App Configuration plugin to import configuration
ibmcloud login --apikey "${{ inputs.IBM_CLOUD_API_KEY }}" -r "${{ inputs.IBM_CLOUD_REGION }}" -g "${{ inputs.IBM_CLOUD_RESOURCE_GROUP }}"
ibmcloud ac init --instance_id "${{ inputs.AC_INSTANCE_ID }}"
ibmcloud ac import --file ./appconfig.json --clean true
else
echo "Configuration file is not updated. No action required"
fi