Skip to content

Git Runner Deployer

Git Runner Deployer #1

name: Git Runner Deployer
on:
workflow_dispatch:
inputs:
playground-account-name:
description: "Enter playground account name"
required: true
env-name:
description: "Enter environment name"
default: "default"
env:
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }}
GITHUB_PAT: ${{ secrets.GH_PAT }}
jobs:
create-napptive-env:
name: Create napptive environment
runs-on: ubuntu-latest
env:
ENV: ${{ github.event.inputs.env-name }}
PLAYGROUND_ACCOUNT_NAME: ${{ github.event.inputs.playground-account-name }}
ORG: ${{ github.repository_owner }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install jq
run: apt install jq
- name: Install napptive CLI
shell: bash
run: curl -O https://storage.googleapis.com/artifacts.playground.napptive.dev/installer.sh && bash installer.sh
- name: Login using PAT
shell: bash
run: playground login --pat
- name: Request Runner token
shell: bash
run: |
RESPONSE=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_PAT" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/$ORG/actions/runners/registration-token)
echo $RESPONSE
TOKEN=$(echo $RESPONSE | jq -r '.token')
- name: Replace token in param file
shell: bash
run: |
sed -i "s/__TOKEN__/$TOKEN/g" param-file.yaml
sed -i "s/__ORGANIZATION__/$ORG/g" param-file.yaml
- name: Use env
shell: bash
run: |
playground env use $PLAYGROUND_ACCOUNT_NAME/$ENV
if [ $? -ne 0 ]; then
playground env create "$PLAYGROUND_ACCOUNT_NAME/$ENV"
echo "ENVIRONMENT CREATED: $PLAYGROUND_ACCOUNT_NAME/$ENV"
playground env use $PLAYGROUND_ACCOUNT_NAME/$ENV
fi
- name: Deploy app
shell: bash
run: |
playground catalog deploy napptive/github-runner:2.298.2 --setParametersFromFile param-file.yaml