Skip to content

Instantly share code, notes, and snippets.

@manstis
Last active July 21, 2023 07:57
Show Gist options
  • Save manstis/72fc33fa6f4e3424a1e3cb2ed11aec3c to your computer and use it in GitHub Desktop.
Save manstis/72fc33fa6f4e3424a1e3cb2ed11aec3c to your computer and use it in GitHub Desktop.
Ansible GPT-SWF
{
"id": "ansible-job",
"version": "1.0",
"specVersion": "0.8",
"name": "Ansible Job",
"description": "Launch an Ansible Job within Ansible Automation Platform",
"start": "Generating the Ansible Job component",
"functions": [
{
"name": "runActionTemplateFetch",
"operation": "specs/actions-openapi.json#fetch:template"
},
{
"name": "runActionGitHubRepoPush",
"operation": "specs/actions-openapi.json#github:repo:push"
},
{
"name": "runActionCatalogRegister",
"operation": "specs/actions-openapi.json#catalog:register"
}
],
"states": [
{
"name": "Generating the Ansible Job component",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"name": "Run Template Fetch Action",
"functionRef": {
"refName": "runActionTemplateFetch",
"arguments": {
"url": "./skeleton",
"targetPath": "argo/ansibleJobs/",
"values": {
"component_id": "${{ .name }}",
"jobTemplate": "${{ .jobTemplate }}",
"name": "${{ .name }}",
"namespace": "${{ .namespace }}",
"connection_secret": "${{ .connection_secret }}"
}
}
},
"actionDataFilter": {
"toStateData": ".actionResult"
}
}
],
"transition": "Generating the Catalog Info Component"
},
{
"name": "Generating the Catalog Info Component",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"functionRef": {
"refName": "runActionTemplateFetch",
"arguments": {
"url": "../../scaffolder-skeletons/catalog-info-skeleton/",
"values": {
"githubOrg": "${{ .githubOrg }}",
"repoName": "${{ .repoName }}",
"owner": "${{ .owner }}",
"applicationType": "api",
"description": "${{ .description }}"
}
}
},
"actionDataFilter": {
"toStateData": ".actionResult"
}
}
],
"transition": "Publish to GitHub"
},
{
"name": "Publish to GitHub",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"functionRef": {
"refName": "runActionGitHubRepoPush",
"arguments": {
"repoUrl": "github.com?owner=${{ parameters.githubOrg }}&repo=${{ parameters.repoName }}",
"protectDefaultBranch": false,
"protectEnforceAdmins": false
}
},
"actionDataFilter": {
"toStateData": ".actionResult"
}
}
],
"transition": "Register Catalog entry"
},
{
"name": "Register Catalog entry",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"functionRef": {
"refName": "runActionCatalogRegister",
"arguments": {
"repoContentsUrl": "${{ steps.publish.output.repoContentsUrl }}",
"catalogInfoPath": "/catalog-info.yaml"
}
},
"actionDataFilter": {
"toStateData": ".actionResult"
}
}
],
"end": true
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment