Skip to content

To Staging: Change to cloud-hosted-guide-testcontainers #1258

To Staging: Change to cloud-hosted-guide-testcontainers

To Staging: Change to cloud-hosted-guide-testcontainers #1258

Workflow file for this run

name: Mirror to GitLab Repos
# 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 "::set-output name=matrixProd::$TASKS"
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 "::set-output name=matrixStaging::$TASKS"
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@v2
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 "${{matrix.repo.gitlab}}"";
GITLAB="${{matrix.repo.gitlab}}" >> $GITHUB_ENV;
GITLAB_BRANCH="${{matrix.repo.gitlab-branch}}" >> $GITHUB_ENV;
else
echo "Skipping "${{matrix.repo.github}}"";
exit 1;
fi
- name: Mirror to Gitlab
uses: s0/git-publish-subdir-action@develop
env:
REPO: git@ssh.author-gitlab.skills.network:quicklabs/${{matrix.repo.gitlab}}.git
BRANCH: ${{matrix.repo.gitlab-branch}}
FOLDER: instructions/${{matrix.repo.github}}
MESSAGE: "{msg}" # Sets the commit message on gitlab to be the same as on github.
SSH_PRIVATE_KEY: ${{secrets.DEPLOY_KEY_QUICK_LABS}}
KNOWN_HOSTS_FILE: .github/workflows/known_hosts # Needed if target repo is not on github.com.
SKIP_EMPTY_COMMITS: "true"
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 Gitlab
uses: s0/git-publish-subdir-action@develop
env:
REPO: git@ssh.author-gitlab.skills.network:quicklabs/${{matrix.repo.gitlab}}.git
BRANCH: ${{matrix.repo.gitlab-branch}}
FOLDER: instructions/${{matrix.repo.github}}
MESSAGE: "{msg}" # Sets the commit message on gitlab to be the same as on github.
SSH_PRIVATE_KEY: ${{secrets.DEPLOY_KEY_QUICK_LABS}}
KNOWN_HOSTS_FILE: .github/workflows/known_hosts # Needed if target repo is not on github.com.
SKIP_EMPTY_COMMITS: "true"
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@v2
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 "${{matrix.repo.gitlab}}"";
GITLAB="${{matrix.repo.gitlab}}" >> $GITHUB_ENV;
GITLAB_BRANCH="${{matrix.repo.gitlab-branch}}" >> $GITHUB_ENV;
else
echo "Skipping "${{matrix.repo.github}}"";
exit 1;
fi
- name: Mirror to Gitlab
uses: s0/git-publish-subdir-action@develop
env:
REPO: git@ssh.author-gitlab.skills.network:quicklabs/${{matrix.repo.gitlab}}.git
BRANCH: ${{matrix.repo.gitlab-branch}}
FOLDER: instructions/${{matrix.repo.github}}
MESSAGE: "{msg}" # Sets the commit message on gitlab to be the same as on github.
SSH_PRIVATE_KEY: ${{secrets.DEPLOY_KEY_QUICK_LABS}}
KNOWN_HOSTS_FILE: .github/workflows/known_hosts # Needed if target repo is not on github.com.
SKIP_EMPTY_COMMITS: "true"
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 Gitlab
uses: s0/git-publish-subdir-action@develop
env:
REPO: git@ssh.author-gitlab.skills.network:quicklabs/${{matrix.repo.gitlab}}.git
BRANCH: ${{matrix.repo.gitlab-branch}}
FOLDER: instructions/${{matrix.repo.github}}
MESSAGE: "{msg}" # Sets the commit message on gitlab to be the same as on github.
SSH_PRIVATE_KEY: ${{secrets.DEPLOY_KEY_QUICK_LABS}}
KNOWN_HOSTS_FILE: .github/workflows/known_hosts # Needed if target repo is not on github.com.
SKIP_EMPTY_COMMITS: "true"
# 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