Configuring the GitHub Actions workflow
To create a new workflow
- On the GitHub Actions tab, click New workflow.
- In the Simple workflow section, click Configure.
- Select the name field that has the default name blank.yml, and enter your workflow name.
- Select the editor and enter your workflow details.
- To save, click Commit changes….
To upload an existing workflow
- On the GitHub Code tab, click the .github/workflows directory to expand it.
- In the upper right-hand corner of the .github/workflows directory, click Add file.
- Click Upload files.
- In the Upload files dialog box, drag the workflow YAML file into the upload files dialog box, or click choose your files to select a workflow YAML file and click Commit changes.
- On the GitHub Code tab, click the .github/workflows directory to expand and select your workflow file.
- On the Code tab, select Edit this file and customize your workflow as needed.
- Click Commit changes….
Customizing your workflow content for BMC AMI DevOps
Define the workflow’s name, trigger event, jobs, container, and repository checkout step as configured in your environment.
In this example, the image specified is your path location for the BMC AMI DevOps Universal Connector image, and you must use the -u <uid> option to pass into the container host.
Define the workflow steps as follows:
To display text in logs, use the Linux echo command.
To replace variable values, use the Linux sed -i command. This applies to all secrets and variables defined in GitHub Actions. You must provide the absolute path of the config YAML file in which the variable is used.
To concatenate the config YAML file in the log and preview the contents, use the Linux cat command.
To run the steps from the config YAML file, specify step stepName and the config YAML file with its repository path. Use the step command to run the application step from the GitHub Actions workflow configuration file. If the config YAML file resides in the repository root path, then the path is not required. The arguments for this command are application step name, config YAML file path, and debug flag.
To use the debug parser option, specify true after the step's config file.To print the step name in the workflow log, specify - name: and the stepName.
To retain and access job output from your workflow run, use GitHub Actions’ actions/upload-artifact@v4, in your workflow yaml file.
- Give the action a name, like ‘Upload artifacts’.
- Set the if condition (${{ success() || failure() }}), so the upload-artifact@v4 runs no matter the previous step result.
- Set path to the workspace relative path (.) to get the files from the workflow workspace.
After the workflow runs, in the beginning of the workflow job console log, it produces an artifact link to the folder and saves the output files from the job as well as repository files.
For more information on the upload-artifact action, see the GitHub Actions documentation.
Sample workflow step script
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out repository
uses: actions/checkout@v3
# Perform various initialization functions using Linux based command sed
- name: Initialization
run: |
echo "Replace variables defined in Config_File_Transmission.yml file"
# Linux command sed is used to replace the config file variables with GitHub Actions secrets and variables
sed -i "s/USER_ID_AUTH/${{vars.user_id}}/" Config_File_Transmission.yml
sed -i "s/USER_PASS_AUTH/${{secrets.user_pass}}/" Config_File_Transmission.yml
# For certBased Authentication, uncomment the following 2 sed commands
# sed -i "s|CERT_PATH_AUTH|/opt/secret/<clientCertificateName>.p12|" Config_File_Transmission.yml
# sed -i "s/CERT_PASS_AUTH/${{secrets.cert_pass}}/" Config_File_Transmission.yml
# Use syntax \<var name\> to find and replace the exact matching word
sed -i "s/\<JOB_ID\>/${{vars.job_id}}/" Config_File_Transmission.yml
sed -i "s/DDL_FILE_FT_UPLOAD/${{vars.ddl_file}}/" Config_File_Transmission.yml
# Use GitHub Actions environment variables to fetch workflow name, run number, run by and run mode of the executing workflow
sed -i "s/PIPELINENAME_VALUE/${{github.workflow}}/" Config_File_Transmission.yml
sed -i "s/RUNNUMBER_VALUE/${{github.run_id}}/" Config_File_Transmission.yml
sed -i "s/RUNBY_VALUE/${{github.actor}}/" Config_File_Transmission.yml
sed -i "s/RUNMODE_VALUE/${{github.event_name}}/" Config_File_Transmission.yml
echo "----- Config_File_Transmission.yml file is updated -----"
# Execute application step - authentication
- name: Authentication
run:
step authentication Config_File_Transmission.yml
# Execute application step - fileUpload (local_to_mainframe)
- name: File Transmission
run:
step local_to_mainframe Config_File_Transmission.yml
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: report
path: .The detailed explanation of the syntax used in the above example is as follows:
The step command for an application step with one mandatory argument is as follows, where <arg> is a required application step name:
step <arg>The step command with the default configuration file config.yml that is maintained under the root directory is as follows:
# Execute application step - authentication
- name: Authentication
run:
step authentication
# Execute application step - fileUpload (local_to_mainframe)
- name: File Transmission
run:
step local_to_mainframeThe example for step command for an application step with more than one argument is as follows:
step <arg1> <arg2> <arg3>In this example, the arguments are defined as follows:
- <arg1> — Required application step name.
- <arg2> — (Optional) Config YAML file path and file name.
- <arg3> — (Optional) Debug flag set as Boolean. The default value is false.
The step command with user-defined config YAML file that is maintained under the root directory is as follows:
# Execute application step - authentication
- name: Authentication
run:
step authentication Config_File_Transmission.yml
# Execute application step - fileUpload (local_to_mainframe)
- name: File Transmission
run:
step local_to_mainframe Config_File_Transmission.ymlThe step command with user-defined config YAML file that is maintained under a directory or sub-directory is as follows:
# Execute application step - authentication
- name: Authentication
run:
step authentication /directory/sub-directory(s)/Config_File_Transmission.yml
# Execute application step - fileUpload (local_to_mainframe)
- name: File Transmission
run:
step local_to_mainframe /directory/sub-directory(s)/Config_File_Transmission.yml
Defining a variable in the workflow
You can define variables for use in a single workflow as an environment variable in the workflow script or for use in multiple workflows as Actions secrets and variables.
For more information, see Variables-for-Universal-Connector.