Tyk Assets Environment Promotion #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tyk Assets Environment Promotion | |
# Perform the env promotion only on push to main branch | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
options: | |
- stg | |
- prod | |
jobs: | |
env-promotion: | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the current repo and fetch only the current commits (JTBD) | |
- name: 'Checkout Repository' | |
uses: actions/checkout@v4 | |
- name: Create .tyk.json | |
run: | | |
cd ./${{ inputs.environment }} | |
echo '{' > .tyk.json | |
echo ' "type": "apidef",' >> .tyk.json | |
echo ' "files": [' >> .tyk.json | |
find . -type f -name '*.json' -path './apis/*' -exec echo ' {"file": "{}"},' \; | sed '$ s/,$//' >> .tyk.json | |
echo ' ],' >> .tyk.json | |
echo ' "policies": [' >> .tyk.json | |
find . -type f -name '*.json' -path './policies/*' -exec echo ' {"file": "{}"},' \; | sed '$ s/,$//' >> .tyk.json | |
echo ' ],' >> .tyk.json | |
echo ' "assets": [' >> .tyk.json | |
find . -type f -name '*.json' -path './assets/*' -exec echo ' {"file": "{}"},' \; | sed '$ s/,$//' >> .tyk.json | |
echo ' ]' >> .tyk.json | |
echo '}' >> .tyk.json | |
cat .tyk.json | |
- name: Sync with Tyk | |
env: | |
TYK_SYNC_REPO: ${{ vars.TYK_SYNC_REPO }} | |
TYK_SYNC_VERSION: ${{ vars.TYK_SYNC_VERSION }} | |
TYK_DASHBOARD_URL: ${{ inputs.environment == 'stg' && secrets.TYK_STG_DASHBOARD_URL || secrets.TYK_PROD_DASHBOARD_URL }} | |
TYK_DASHBOARD_SECRET: ${{ inputs.environment == 'stg' && secrets.TYK_STG_DASHBOARD_SECRET || secrets.TYK_PROD_DASHBOARD_SECRET }} | |
run: | | |
docker run ${TYK_SYNC_REPO}:${TYK_SYNC_VERSION} version | |
docker run -v ${{ github.workspace }}/${{ inputs.environment }}:/app/data ${TYK_SYNC_REPO}:${TYK_SYNC_VERSION} sync --path /app/data --dashboard ${TYK_DASHBOARD_URL} --secret ${TYK_DASHBOARD_SECRET} |