feat(feedback): Add feedback plugin annotations to catalog entities (… #97
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: Auto deployment for dev and qa | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
get-changes-for-spas: | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
# Outputs all changed files in a json format to start matrix jobs | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Check changed files | |
id: changed-files | |
uses: tj-actions/[email protected] | |
with: | |
dir_names: true | |
json: true | |
- name: Get dir names | |
id: get-dir-names | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const folders = JSON.parse("${{ steps.changed-files.outputs.all_changed_files }}"); | |
const newArr = []; | |
for (let folder of folders) { | |
if (folder.startsWith('packages')) { | |
const folderNameParts = folder.split('/'); | |
const folderName = `${folderNameParts[0]}/${folderNameParts[1]}` | |
if (!newArr.includes(folderName)) { | |
if(folderName.endsWith('spa')) { | |
newArr.push(folderName) | |
} | |
} | |
} | |
} | |
core.setOutput('dir_names', JSON.stringify(JSON.stringify(newArr))) | |
- id: set-matrix | |
run: echo "matrix={\"container\":${{ steps.get-dir-names.outputs.dir_names }}}" >> "$GITHUB_OUTPUT" | |
# Steps in the following Job | |
# #1 cd into dir | |
# #2 get env file from gitlab (note: without the full url curl does not resolve the endpoint) | |
# #3 install the required node_modules | |
# #4 build with the .env file | |
# #5 deploy using spaship cli | |
matrix-job: | |
name: Job for ${{ matrix.container }} | |
timeout-minutes: 20 | |
runs-on: self-hosted | |
needs: [get-changes-for-spas] | |
strategy: | |
matrix: ${{ fromJSON(needs.get-changes-for-spas.outputs.matrix) }} | |
max-parallel: 4 | |
fail-fast: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
if: contains(matrix.container, '-spa') | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
if: contains(matrix.container, '-spa') | |
with: | |
node-version: 16 | |
cache: 'npm' | |
- name: Get SPA NAME as strings | |
id: get-spa-name | |
if: contains(matrix.container, '-spa') | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const spaName = "${{ matrix.container }}".split('/')[1]; | |
core.setOutput('LIGHTHOUSE_BRANCH_NAME', spaName.toUpperCase()) | |
core.setOutput('SPA_NAME', spaName) | |
- name: Get env secrets for QA | |
if: contains(matrix.container, '-spa') | |
run: | | |
cd ${{ matrix.container }} | |
curl -k --header "PRIVATE-TOKEN:${{ secrets.GITLAB_TOKEN }}" "${{ secrets.GITLAB_URL }}spa-configs%2Fqa%2F${{ steps.get-spa-name.outputs.SPA_NAME }}%2F.env/raw?ref=master" -o .env | |
- name: Install node modules | |
if: contains(matrix.container, '-spa') | |
run: | | |
cd ${{ matrix.container }} | |
npm install | |
- name: Build SPA | |
if: contains(matrix.container, '-spa') | |
run: | | |
cd ${{ matrix.container }} | |
npm run build | |
- name: Deploy SPA on QA | |
if: contains(matrix.container, '-spa') | |
run: | | |
cd ${{ matrix.container }} | |
npx @spaship/cli@latest deploy --apikey=${{ secrets.SPASHIP_API_KEY }} --env=${{ secrets.SPASHIP_DEPLOY_URL }}qa --ref=$(node -p "require('./package.json').version") |