|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: Submit |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the main branch |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + paths: |
| 12 | + - "package.json" |
| 13 | + # Allows you to run this workflow manually from the Actions tab |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + allow_error: |
| 17 | + description: "allow a workflow run from failing when a job fails" |
| 18 | + required: false |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v3 |
| 26 | + with: |
| 27 | + # persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. |
| 28 | + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. |
| 29 | + - name: Get yarn cache directory path |
| 30 | + id: yarn-cache-dir-path |
| 31 | + run: echo "::set-output name=dir::node_modules" |
| 32 | + |
| 33 | + - uses: actions/cache@v3 |
| 34 | + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
| 35 | + with: |
| 36 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 37 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-yarn- |
| 40 | +
|
| 41 | + - name: Install NPM dependencies |
| 42 | + run: yarn install |
| 43 | + |
| 44 | + - name: Get submit version |
| 45 | + id: version |
| 46 | + uses: ashley-taylor/read-json-property-action@v1.0 |
| 47 | + with: |
| 48 | + path: ./package.json |
| 49 | + property: version |
| 50 | + |
| 51 | + # develop submit |
| 52 | + - name: Submit Widget develop |
| 53 | + continue-on-error: ${{ inputs.allow_error }} |
| 54 | + run: | |
| 55 | + echo "Submit Widget develop" |
| 56 | + npx -y @apitable/widget-cli submit --version ${{steps.version.outputs.value}} --host ${{ secrets.DEVELOP_HOST }} --token ${{ secrets.DEVELOP_TOKEN }} |
| 57 | +
|
| 58 | + # production submit |
| 59 | + - name: Submit Widget production |
| 60 | + continue-on-error: ${{ inputs.allow_error }} |
| 61 | + run: | |
| 62 | + echo "Submit Widget production" |
| 63 | + npx -y @apitable/widget-cli submit --version ${{steps.version.outputs.value}} --host ${{ secrets.PRODUCTION_HOST }} --token ${{ secrets.PRODUCTION_TOKEN }} |
0 commit comments