Skip to content

Commit

Permalink
adding GAM
Browse files Browse the repository at this point in the history
  • Loading branch information
dchourasia committed Jul 5, 2024
1 parent c378039 commit f56a47c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 36 deletions.
54 changes: 25 additions & 29 deletions .github/workflows/Gated-Auto-Merger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,31 @@ jobs:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
pip install -r utils/auto-merge/requirements.txt
- name: Add the release to config
pip install -r requirements.txt
- name: Trigger GAM
env:
SMARTSHEET_ACCESS_TOKEN: ${{ secrets.SMARTSHEET_ACCESS_TOKEN }}
BUILD_SHEET_ID: ${{ secrets.BUILD_SHEET_ID }}
HYDRA_TOKEN: ${{ secrets.HYDRA_TOKEN }}
shell: bash
id: remove_release_from_config
id: trigger_gam
run: |
RELEASE_TO_BE_SETUP=DEFAULT
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]
then
RELEASE_TO_BE_SETUP=${{ github.event.inputs.release }}
fi
echo "RELEASE_TO_BE_SETUP=$RELEASE_TO_BE_SETUP"
echo $RELEASE_TO_BE_SETUP > RELEASE_TO_BE_SETUP
python utils/auto-merge/setup_release_branches.py --release $RELEASE_TO_BE_SETUP
RELEASE_TO_BE_SETUP=$(cat RELEASE_TO_BE_SETUP)
echo "RELEASE_TO_BE_SETUP=${RELEASE_TO_BE_SETUP}" >> $GITHUB_OUTPUT
rm -rf RELEASE_TO_BE_SETUP
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Commit and push changes to main branch
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.extract_branch.outputs.branch }}
message: "Adding ${{ steps.remove_release_from_config.outputs.RELEASE_TO_BE_SETUP }} to releases.yaml"
repository: red-hat-data-services/rhods-devops-infra
python src/main.py --component ${{ github.event.inputs.component }}
echo "inside main"
pwd
ls
ls /tmp
- uses: actions/checkout@v3
ref: metadata
path: metadata
- name: Copy metadata Json
id: copy_meta
run: |
echo "inside metadata"
pwd
ls
# - name: Commit and push changes to main branch
# uses: actions-js/push@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: metadata
# message: "Adding ${{ steps.remove_release_from_config.outputs.RELEASE_TO_BE_SETUP }} to releases.yaml"
# repository: red-hat-data-services/rhods-devops-infra
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
boto3~=1.26.111
smartsheet-python-sdk~=3.0.2
requests~=2.28.2
Empty file removed src/gam_commons.py
Empty file.
5 changes: 3 additions & 2 deletions src/gam_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def generate_execution_id(self):
def generate_execution_metadata(self):
meta = self.component_config
meta['execution_id'] = self.execution_id
with open('tmp/metadata.yaml', 'w') as metadata:
metadata.write(yaml.dump(meta))
return meta

def post_umb_message(self):
Expand All @@ -36,8 +38,7 @@ def post_umb_message(self):
print(os.getcwd())
url = "https://api.enterprise.redhat.com/hydra/umb-bridge/v1/publish"
payload = json.load(open('data/umb_payload_template.json'))
payload['gam'] |= self.component_config
payload['gam']['execution_id'] = self.execution_id
payload['gam'] |= self.execution_metadata
print('hydra payload ', payload)
payload = json.dumps(payload)
secret_token = os.getenv('HYDRA_TOKEN') # Retrieve secret token from environment variable
Expand Down
7 changes: 5 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import argparse

if __name__ == '__main__':
gc = gam_controller('Dashboard')
parser = argparse.ArgumentParser()
parser.add_argument('--component', required=True, help='Name of the Business Component', dest='component')
args = parser.parse_args()
gc = gam_controller(args.component)
print(gc.component_config)
gc.post_umb_message()
# gc.post_umb_message()
6 changes: 3 additions & 3 deletions src/poc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import yaml
from datetime import datetime

# components = yaml.load(open('../config/components.yaml'), Loader=yaml.SafeLoader)
# print(components)

components = yaml.load(open('../config/gam-config.yaml'), Loader=yaml.SafeLoader)
print(components)
print(yaml.dump(components))
print(datetime.now().strftime('%d%m%y%H%M%S%f'))

0 comments on commit f56a47c

Please sign in to comment.