Skip to content

Update package.json

Update package.json #4

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
create_release:
runs-on: ubuntu-latest
outputs:
release_id: ${{steps.create_release.outputs.id}}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
release_name: Thin-Edge profile plugin draft
tag_name: ${{ github.ref }}
draft: true
prerelease: false
web_build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: [create_release]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Build webapp
run: |
export NODE_OPTIONS=--openssl-legacy-provider
cd web/thinedgeprofile
npm install --force
npm run build
cd dist/apps/sag-ps-iot-pkg-tedge-profile-plugin
zip -r sag-ps-iot-pkg-tedge-profile-plugin *
- name: Create Release
uses: actions/github-script@v6
env:
RELEASE_ID: ${{needs.create_release.outputs.release_id}}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: process.env.RELEASE_ID,
name: 'sag-ps-iot-pkg-tedge-profile-plugin.zip',
data: await fs.readFile('web/thinedgeprofile/dist/apps/sag-ps-iot-pkg-tedge-profile-plugin/sag-ps-iot-pkg-tedge-profile-plugin.zip')
});
clean_up_if_failure:
runs-on: ubuntu-latest
needs: [web_build]
steps:
- name: Delete release if clean_up_if_failure
if: ${{failure()}}
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const release = await github.repos.getReleaseByTag({
owner, repo, process.env.GITHUB_REF
})
await github.repos.deleteRelease({owner, repo, release.data.id})