Skip to content

Merge pull request #62 from ezeep/feature/icons_and_markup_fixes #230

Merge pull request #62 from ezeep/feature/icons_and_markup_fixes

Merge pull request #62 from ezeep/feature/icons_and_markup_fixes #230

Workflow file for this run

# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js Build
env:
MODULE_VERSION: '1.0.${{ github.run_number }}' # update MAJOR and MINOR version here
DIST_PATH: 'dist/ezeep' # deployment path
ARTIFACT_NAME: 'ezeep-js.zip' # artifact name
DIST_PATH_NG: 'dist/directives' # angular directives deployment path
ARTIFACT_NAME_NG: 'ng-directives.zip' # angular directives artifact name
NPM_REGISTRY: 'https://registry.npmjs.org' # npm registry url
PRERELEASE: false # true if marked as pre-release, false if production-ready
on:
push:
branches: [ main ]
jobs:
build-npm:
environment: Production
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout main branch
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: "${{ env.NPM_REGISTRY }}"
cache: 'npm'
- name: Bump package.json version of npm package
uses: reedyuk/npm-version@1.1.1
with:
version: "${{ env.MODULE_VERSION }}"
- name: Build
run: |
npm ci
npm run build
- name: Publish npm package to npm registry
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload npm artifact
uses: actions/upload-artifact@v2
with:
path: ${{ env.DIST_PATH }}
name: ${{ env.ARTIFACT_NAME }}
- name: Upload ng directives artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ env.DIST_PATH_NG }}
name: ${{ env.ARTIFACT_NAME_NG }}
- name: Zip npm artifact for release
uses: thedoctor0/zip-release@master
with:
type: 'zip'
directory: ${{ env.DIST_PATH }}
path: '.'
filename: ${{ env.ARTIFACT_NAME }}
- name: Create release with npm package
uses: ncipollo/release-action@v1
with:
tag: "${{ env.MODULE_VERSION }}"
prerelease: ${{ env.PRERELEASE }}
artifacts: "${{ env.DIST_PATH }}/${{ env.ARTIFACT_NAME }}"
token: ${{ secrets.GITHUB_TOKEN }}
build-ng:
environment: Production
needs: build-npm
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout angular branch
uses: actions/checkout@v2
with:
ref: ngx-ezeep-js
- name: Bump package.json version for angular component
uses: reedyuk/npm-version@1.1.1
with:
package: 'ezeep-js-angular/projects/ngx-ezeep-js'
version: "${{ env.MODULE_VERSION }}"
- name: download angular build artifact
uses: actions/download-artifact@v2
with:
name: ng-directives.zip
path: ezeep-js-angular/projects/ngx-ezeep-js/src/lib
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: "${{ env.NPM_REGISTRY }}"
cache: 'npm'
cache-dependency-path: 'ezeep-js-angular/projects/ngx-ezeep-js'
- name: build angular library and publish
run: |
cd ezeep-js-angular
npm install -g @angular/cli
npm install
cd projects/ngx-ezeep-js
npm install
cd ../..
ng build ngx-ezeep-js --prod
cd dist/ngx-ezeep-js
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
cdn-upload-npm:
environment: Production
needs: build-npm
runs-on: ubuntu-latest
steps:
- name: Download npm artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.ARTIFACT_NAME }}
path: "artifacts/v${{ env.MODULE_VERSION }}"
- name: Login to Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload artifact to blob storage
run: |
azenv='${{ secrets.AZURE_ENVIRONMENT }}'
account=$(jq -crM .storage.account <<< $azenv)
container=$(jq -crM .storage.container <<< $azenv)
az storage blob upload-batch \
--auth-mode login \
--account-name $account \
-d $container \
-s "artifacts" \
-o none
- name: Update Url redirect
run: |
azenv='${{ secrets.AZURE_ENVIRONMENT }}'
resourceGroup=$(jq -crM .resourceGroup <<< $azenv)
profile=$(jq -crM .cdn.profileName <<< $azenv)
endpoint=$(jq -crM .cdn.endpoint.name <<< $azenv)
rules=$(jq -crM .cdn.endpoint.rules[].name <<< $azenv)
container=$(jq -crM .storage.container <<< $azenv)
for rule in $rules; do
fileName=$(jq -crM --arg rule "$rule" \
'.cdn.endpoint.rules[]
| select(.name == $rule)
| .fileName' \
<<< $azenv)
index=$(az cdn endpoint rule action show \
-g $resourceGroup \
--profile-name $profile \
-n $endpoint \
| jq --arg rule "$rule" '.deliveryPolicy.rules[]
| select(.name == $rule)
| .actions | to_entries | .[]
| select(.value.name == "UrlRedirect") | .key' \
)
az cdn endpoint rule action remove \
-g $resourceGroup \
--profile-name $profile \
-n $endpoint \
--rule-name $rule \
--index $index \
-o none
az cdn endpoint rule action add \
-g $resourceGroup \
--profile-name $profile \
-n $endpoint \
--rule-name $rule \
--action-name UrlRedirect \
--custom-path "/$container/v${{ env.MODULE_VERSION }}/$fileName" \
--redirect-type Found \
-o none
done
- name: Purge CDN endpoint
run: |
azenv='${{ secrets.AZURE_ENVIRONMENT }}'
resourceGroup=$(jq -crM .resourceGroup <<< $azenv)
profile=$(jq -crM .cdn.profileName <<< $azenv)
endpoint=$(jq -crM .cdn.endpoint.name <<< $azenv)
container=$(jq -crM .storage.container <<< $azenv)
az cdn endpoint purge \
-g $resourceGroup \
--profile-name $profile \
-n $endpoint \
--content-paths "/$container/*" \
--no-wait \
-o none
- name: Azure CLI logout
run: |
az logout
az cache purge
az account clear
if: always()