ref: updated netlify action version #56
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: Deploy Static Portal | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
generate-portal: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
name : checkout-repo | |
id: checkout-repo | |
- name: Zip files | |
run: zip -qq -r portal-input.zip . | |
# Call Apimatic Endpoint to generate Portal | |
- name: Call build endpoint | |
id: generate-portal | |
run: | | |
RESPONSE=`curl -s --write-out '%{http_code}\t%{content_type}' --request POST --url 'https://api.apimatic.io/portal' \ | |
-H 'Authorization:X-Auth-Key ${{ secrets.API_KEY }}' -F '[email protected]' -OJ`; | |
HTTP_CODE=$(echo $RESPONSE | cut -d " " -f 1); | |
CONTENT_TYPE=$(echo $RESPONSE | cut -d " " -f 2); | |
echo "HTTP_CODE=$HTTP_CODE" >> $GITHUB_OUTPUT; | |
echo "CONTENT_TYPE=$CONTENT_TYPE" >> $GITHUB_OUTPUT; | |
- name: list | |
run: ls | |
- name: Extract generated Portal | |
if: ${{steps.generate-portal.outputs.HTTP_CODE == '200'}} | |
run: unzip -qq portal.zip -d static-portal | |
- name: list | |
run: ls | |
- name: Deploy to Netlify | |
if: ${{steps.generate-portal.outputs.HTTP_CODE == '200'}} | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: './static-portal' | |
production-branch: master | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "Deploy from GitHub Actions" | |
enable-pull-request-comment: false | |
enable-commit-comment: true | |
overwrites-pull-request-comment: true | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
timeout-minutes: 2 | |
# Upload Portal Artifact | |
- name: Upload Artifact | |
if: ${{steps.generate-portal.outputs.HTTP_CODE == '200' }} | |
uses: actions/[email protected] | |
with: | |
name: static-portal | |
path: static-portal | |
# Unzip error file if error code is 422 with a zip file | |
- name: Unzip error file | |
if: ${{steps.generate-portal.outputs.HTTP_CODE == '422' && steps.generate-portal.outputs.CONTENT_TYPE == 'application/zip'}} | |
run: unzip -qq error.zip -d error | |
# Upload error.zip if error code is 422 with a zip file | |
- name: Upload error.zip | |
if: ${{steps.generate-portal.outputs.HTTP_CODE == '422' && steps.generate-portal.outputs.CONTENT_TYPE == 'application/zip'}} | |
uses: actions/[email protected] | |
with: | |
name: error | |
path: error | |
# Fail job if API response is not 200 | |
- name: Log error if not successful | |
if: ${{steps.generate-portal.outputs.HTTP_CODE != '200' && steps.generate-portal.outputs.CONTENT_TYPE != 'application/zip'}} | |
run: | | |
echo "The Portal Generation request failed with response code ${{steps.generate-portal.outputs.HTTP_CODE}} and message $(cat portal)"; \ | |
exit 1 | |
# Fail job if API response is not 200 and is a zip file | |
- name: Log error if not successful | |
if: ${{steps.generate-portal.outputs.HTTP_CODE != '200' && steps.generate-portal.outputs.CONTENT_TYPE == 'application/zip'}} | |
run: | | |
echo "The Portal Generation request failed with response code ${{steps.generate-portal.outputs.HTTP_CODE}}; \ | |
exit 1 | |