Skip to content

[Comgr] Explicitly describe data object mutation restrictions (#746) #55

[Comgr] Explicitly describe data object mutation restrictions (#746)

[Comgr] Explicitly describe data object mutation restrictions (#746) #55

name: Trigger compute-rocm-dkms-afar job on push
on:
push: # This triggers the workflow on push events
branches:
- amd-staging
workflow_dispatch: # This allows manual triggering of the workflow
jobs:
trigger_jenkins:
runs-on: self-hosted
steps:
- name: Set environment variable for container image
run: |
echo "CONTAINER_IMAGE=${{ secrets.JENKINS_TRIGGER_DOCKER_IMAGE }}" >> $GITHUB_ENV
echo "CONTAINER_NAME=my_container_${{ github.run_id }}" >> $GITHUB_ENV
- name: Pull container image
run: docker pull "${{env.CONTAINER_IMAGE}}"
- name: Run container
run: |
docker run -d --name "${{env.CONTAINER_NAME}}" $CONTAINER_IMAGE sleep infinity
docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "echo 'Running commands inside the container'"
- name: Trigger compute-rocm-dkms-afar job
run: |
docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "python -c \"
import requests
import time
from requests.auth import HTTPBasicAuth
jenkins_user = '${{ secrets.CI_JENKINS_USER }}'
jenkins_token = '${{ secrets.ROCM_JENKINS_CI_TOKEN }}'
jenkins_host = '${{ secrets.ROCM_JENKINS_HOST }}'
jenkins_job = '${{ secrets.ROCM_JENKINS_OSDB_JOB }}'
jenkins_url = f'{jenkins_host}/job/{jenkins_job}/buildWithParameters'
response = requests.post(jenkins_url, auth=HTTPBasicAuth(jenkins_user, jenkins_token))
if response.status_code == 201:
print('Jenkins job triggered successfully!')
queue_url = response.headers.get('Location')
if queue_url:
print(f'Queue URL: {queue_url}')
print(f'Getting build URL(max 5 attempts with 10seconds interval)...')
# Poll the queue item to get the build number, limited to 5 attempts
max_attempts = 5
attempts = 0
while attempts < max_attempts:
queue_response = requests.get(queue_url + 'api/json', auth=HTTPBasicAuth(jenkins_user, jenkins_token))
queue_data = queue_response.json()
if 'executable' in queue_data:
build_number = queue_data['executable']['number']
build_url = f'{jenkins_host}/job/{jenkins_job}/{build_number}/'
print(f'Build URL: {build_url}')
break
attempts += 1
time.sleep(10) # Wait for 10 seconds before polling again
else:
print('Exceeded maximum attempts to get the build URL. The trigger happened, so not failing the workflow')
else:
print('Build URL not found in the response headers.')
elif response.status_code == 200:
print('Request was successful, but check the response content for details.')
print(response.text)
else:
print(f'Failed to trigger Jenkins job. Status code: {response.status_code}')
\""
- name: Stop and remove container
if: always()
run: |
docker stop "${{env.CONTAINER_NAME}}"
docker rm "${{env.CONTAINER_NAME}}"