|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [ '*' ] |
| 6 | + branches: [ main ] |
| 7 | + pull_request: |
| 8 | + branches: [ main ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + name: Build and publish UI bundle |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Set up NodeJS 18 |
| 19 | + uses: actions/setup-node@v3 |
| 20 | + with: |
| 21 | + node-version: '18.x' |
| 22 | + |
| 23 | + - name: Build project |
| 24 | + run: npm install |
| 25 | + |
| 26 | + - name: Create UI bundle |
| 27 | + run : gulp bundle |
| 28 | + |
| 29 | + - name: If pushed to main, delete 'latest' tag if any |
| 30 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 31 | + uses: actions/github-script@v3 |
| 32 | + with: |
| 33 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 34 | + script: | |
| 35 | + try { |
| 36 | + await github.git.deleteRef({ |
| 37 | + owner: context.repo.owner, |
| 38 | + repo: context.repo.repo, |
| 39 | + ref: "tags/latest" |
| 40 | + }) |
| 41 | + console.log("The 'latest' tag has been deleted") |
| 42 | + } catch (e) { |
| 43 | + console.log("The 'latest' tag doesn't exist yet: " + e) |
| 44 | + } |
| 45 | +
|
| 46 | + - name: If pushed to main, set 'latest' tag on current build |
| 47 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 48 | + uses: mathieudutour/[email protected] |
| 49 | + with: |
| 50 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + tag_prefix: '' |
| 52 | + custom_tag: latest |
| 53 | + |
| 54 | + - name: If pushed to main or tagged, publish UI bundle |
| 55 | + if: github.event_name == 'push' |
| 56 | + uses: softprops/action-gh-release@v1 |
| 57 | + with: |
| 58 | + name: Latest UI bundle |
| 59 | + files: build/ui-bundle.zip |
| 60 | + tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }} |
| 61 | + |
| 62 | + - name: If published, trigger redeployment of playbook |
| 63 | + if: github.event_name == 'push' |
| 64 | + uses: convictional/[email protected] |
| 65 | + with: |
| 66 | + github_token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }} |
| 67 | + owner: ${{ github.repository_owner }} |
| 68 | + repo: microprofile-documentation |
| 69 | + workflow_file_name: build-and-deploy.yml |
| 70 | + wait_interval: 3 |
| 71 | + wait_workflow: false |
| 72 | + propagate_failure: false |
0 commit comments