Skip to content

To Prod: Change to cloud-hosted-guide-grpc-intro #1731

To Prod: Change to cloud-hosted-guide-grpc-intro

To Prod: Change to cloud-hosted-guide-grpc-intro #1731

Workflow file for this run

name: Mirror to AWB
# Triggers the workflow on push events but only for the prod branch.
on:
pull_request:
types:
- closed
paths:
- 'instructions/**'
jobs:
matrixProd:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrixProd }}
steps:
# Any prerequisite steps
- uses: actions/checkout@master
- id: set-matrix
run: |
TASKS=$(echo $(cat $GITHUB_WORKSPACE/.github/workflows/mirror.json))
TASKS="${TASKS//'%'/'%25'}"
TASKS="${TASKS//$'\n'/'%0A'}"
TASKS="${TASKS//$'\r'/'%0D'}"
echo "matrixProd=$TASKS" >> $GITHUB_OUTPUT
matrixStaging:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrixStaging }}
steps:
# Any prerequisite steps
- uses: actions/checkout@master
- id: set-matrix
run: |
TASKS=$(echo $(cat $GITHUB_WORKSPACE/.github/workflows/StagingMirror.json))
TASKS="${TASKS//'%'/'%25'}"
TASKS="${TASKS//$'\n'/'%0A'}"
TASKS="${TASKS//$'\r'/'%0D'}"
echo "matrixStaging=$TASKS" >> $GITHUB_OUTPUT
singleMergedToProd:
name: Check if PR was a single Guide merged to Prod
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'prod' && contains( github.event.pull_request.title,'Change to cloud-hosted')
runs-on: ubuntu-latest
steps:
- name: Upload guide name
run: |
echo The PR was merged
echo ${{ github.event.pull_request.title }} | sed 's/.* Change to //' > guide_name.txt
- uses: actions/upload-artifact@v4
with:
name: guide_name
path: guide_name.txt
deployProd:
needs: [singleMergedToProd, matrixProd]
# name: Start Mirror Containers for single Guide for Prod
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
repo: ${{fromJson(needs.matrixProd.outputs.matrix)}}
steps:
- uses: actions/download-artifact@v2
with:
name: guide_name
- run: |
echo "GUIDENAME=$(cat guide_name.txt)" >> $GITHUB_ENV
# Any prerequisite steps
- uses: actions/checkout@master
- name: Check Files
run: |
if [ "${{ env.GUIDENAME }}" = "${{matrix.repo.github}}" ]; then
echo "Mirroring "${{ env.GUIDENAME }}" to AuthorWorkbench";
echo "awb url: https://author.skills.network/quicklabs/${{matrix.repo.quicklab_id}}/labs/${{matrix.repo.lab_id}}";
else
echo "Skipping "${{matrix.repo.github}}"";
exit 1;
fi
- name: Mirror to AWB
env:
LAB_ID: ${{ matrix.repo.lab_id }}
OAUTH_TOKEN: ${{ secrets.AWB_OAUTH_TOKEN }}
FILE_PATH: instructions/${{ matrix.repo.github }}/instructions.md
PUBLISH: true
run: |
chmod +x ${{ github.workspace }}/.github/workflows/deploy_guide.sh
${{ github.workspace }}/.github/workflows/deploy_guide.sh $LAB_ID $OAUTH_TOKEN $FILE_PATH "$(git log -1 --pretty=format:"%s" -- $FILE_PATH)" $PUBLISH "https://author.skills.network"
deployAllToProd:
needs: matrixProd
# name: Start Mirror Containers for all Guides for Prod
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'prod' && contains( github.event.pull_request.title,'Change to multiple Guides')
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix: # Uses an array of Json variables to pass the repo names.
# The names differ between Github and Gitlab so this is necessary.
# Add new cloud-hosted-guides here to add them to the mirror process.
# i.e. {"github":"new-lab-github-url","gitlab":"new-lab-gitlab-url"}
repo: ${{fromJson(needs.matrixProd.outputs.matrix)}}
steps:
# Any prerequisite steps
- uses: actions/checkout@master
- name: Mirror to AWB
env:
LAB_ID: ${{ matrix.repo.lab_id }}
OAUTH_TOKEN: ${{ secrets.AWB_OAUTH_TOKEN }}
FILE_PATH: instructions/${{ matrix.repo.github }}/instructions.md
PUBLISH: true
run: |
chmod +x ${{ github.workspace }}/.github/workflows/deploy_guide.sh
${{ github.workspace }}/.github/workflows/deploy_guide.sh $LAB_ID $OAUTH_TOKEN $FILE_PATH "$(git log -1 --pretty=format:"%s" -- $FILE_PATH)" $PUBLISH "https://author.skills.network"
singleMergedToStaging:
name: Check if PR was a single Guide merged to Staging
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging' && contains( github.event.pull_request.title,'Change to cloud-hosted')
runs-on: ubuntu-latest
steps:
- name: Upload guide name
run: |
echo The PR was merged
# echo the PR title and trim only the guide name for example "To Prod: Change to cloud-hosted-guide-jakarta-websocket" = "cloud-hosted-guide-jakarta-websocket"
echo ${{ github.event.pull_request.title }} | sed 's/.* Change to //' > guide_name.txt
- uses: actions/upload-artifact@v4
with:
name: guide_name
path: guide_name.txt
deployStaging:
needs: [singleMergedToStaging, matrixStaging]
# name: Start Mirror Containers for single Guide for Staging
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
repo: ${{fromJson(needs.matrixStaging.outputs.matrix)}}
steps:
- uses: actions/download-artifact@v2
with:
name: guide_name
- run: |
echo "GUIDENAME=$(cat guide_name.txt)" >> $GITHUB_ENV
# Any prerequisite steps
- uses: actions/checkout@master
with:
ref: staging
- name: Check Files
run: |
if [ "${{ env.GUIDENAME }}" = "${{matrix.repo.github}}" ]; then
echo "Mirroring "${{ env.GUIDENAME }}" to AuthorWorkbench";
echo "awb url: https://author-workbench.skills.network/quicklabs/${{matrix.repo.quicklab_id}}/labs/${{matrix.repo.lab_id}}";
else
echo "Skipping "${{matrix.repo.github}}"";
exit 1;
fi
- name: Mirror to AWB
env:
LAB_ID: ${{ matrix.repo.lab_id }}
OAUTH_TOKEN: "${{ secrets.AWB_OAUTH_TOKEN }}"
PUBLISH: false
FILE_PATH: "instructions/${{ matrix.repo.github }}/instructions.md"
run: |
chmod +x ${{ github.workspace }}/.github/workflows/deploy_guide.sh
${{ github.workspace }}/.github/workflows/deploy_guide.sh $LAB_ID $OAUTH_TOKEN $FILE_PATH "$(git log -1 --pretty=format:"%s" -- $FILE_PATH)" $PUBLISH "https://author.skills.network"
deployAllToStaging:
needs: matrixStaging
# name: Start Mirror Containers for all Guides for Staging
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'staging' && contains( github.event.pull_request.title,'Change to multiple Guides')
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
repo: ${{fromJson(needs.matrixStaging.outputs.matrix)}}
steps:
# Any prerequisite steps
- uses: actions/checkout@master
with:
ref: staging
- name: Mirror to AWB
env:
LAB_ID: ${{ matrix.repo.lab_id }}
OAUTH_TOKEN: "${{ secrets.AWB_OAUTH_TOKEN }}"
PUBLISH: false
FILE_PATH: "instructions/${{ matrix.repo.github }}/instructions.md"
run: |
chmod +x ${{ github.workspace }}/.github/workflows/deploy_guide.sh
${{ github.workspace }}/.github/workflows/deploy_guide.sh $LAB_ID $OAUTH_TOKEN $FILE_PATH "$(git log -1 --pretty=format:"%s" -- $FILE_PATH)" $PUBLISH "https://author.skills.network"
# Output link to staged files
- name: Print staging lab URL
run: echo "Staging quicklab available at https://labs.cognitiveclass.ai/tools/theiadocker/lab/tree?md_instructions_url=https://cf-course-data-staging.s3.us-east.cloud-object-storage.appdomain.cloud/${{matrix.repo.gitlab}}/instructions.md"
shell: bash