|
1 | 1 | name: Build and publish the ZIP build file |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [opened, synchronize, ready_for_review] |
6 | | - branches-ignore: |
7 | | - - 'dependabot/**' |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, ready_for_review] |
| 6 | + branches-ignore: |
| 7 | + - "dependabot/**" |
8 | 8 | jobs: |
9 | | - dev-zip: |
10 | | - name: Build ZIP and upload to s3 |
11 | | - if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]' |
12 | | - runs-on: ubuntu-latest |
13 | | - outputs: |
14 | | - branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }} |
15 | | - git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }} |
16 | | - steps: |
17 | | - - name: Check out source files |
18 | | - uses: actions/checkout@v4 |
19 | | - - name: Get Composer Cache Directory |
20 | | - id: composer-cache |
21 | | - run: | |
22 | | - echo "::set-output name=dir::$(composer config cache-files-dir)" |
23 | | - - name: Configure Composer cache |
24 | | - uses: actions/cache@v1 |
25 | | - with: |
26 | | - path: ${{ steps.composer-cache.outputs.dir }} |
27 | | - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
28 | | - restore-keys: | |
29 | | - ${{ runner.os }}-composer- |
30 | | - - name: Install composer deps |
31 | | - run: composer install --no-dev --prefer-dist --no-progress --no-suggest |
32 | | - - name: Install npm deps |
33 | | - run: npm ci |
34 | | - - name: Build files |
35 | | - run: npm run build |
36 | | - - name: Create zip |
37 | | - run: npm run dist |
38 | | - - name: Retrieve branch name |
39 | | - id: retrieve-branch-name |
40 | | - run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" |
41 | | - - name: Retrieve git SHA-8 string |
42 | | - id: retrieve-git-sha-8 |
43 | | - run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" |
44 | | - - name: Upload Latest Version to S3 |
45 | | - uses: jakejarvis/s3-sync-action@master |
46 | | - with: |
47 | | - args: --acl public-read --follow-symlinks --delete |
48 | | - env: |
49 | | - AWS_S3_BUCKET: ${{ secrets.AWS_DEV_BUCKET }} |
50 | | - AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_KEY_ARTIFACTS }} |
51 | | - AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ARTIFACTS }} |
52 | | - SOURCE_DIR: artifact/ |
53 | | - DEST_DIR: ${{ github.event.pull_request.base.repo.name }}-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}/ |
54 | | - |
55 | | - comment-on-pr: |
56 | | - name: Comment on PR with links to plugin ZIPs |
57 | | - if: ${{ github.head_ref && github.head_ref != null && github.actor != 'dependabot[bot]' }} |
58 | | - runs-on: ubuntu-latest |
59 | | - needs: dev-zip |
| 9 | + dev-zip: |
| 10 | + name: Build ZIP and upload to s3 |
| 11 | + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]' |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }} |
| 15 | + git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }} |
| 16 | + steps: |
| 17 | + - name: Check out source files |
| 18 | + uses: actions/checkout@v4 |
| 19 | + - name: Install composer deps |
| 20 | + run: composer install --no-dev --prefer-dist --no-progress --no-suggest |
| 21 | + - name: Install npm deps |
| 22 | + run: npm ci |
| 23 | + - name: Build files |
| 24 | + run: npm run build |
| 25 | + - name: Create zip |
| 26 | + run: npm run dist |
| 27 | + - name: Retrieve branch name |
| 28 | + id: retrieve-branch-name |
| 29 | + run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" |
| 30 | + - name: Retrieve git SHA-8 string |
| 31 | + id: retrieve-git-sha-8 |
| 32 | + run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" |
| 33 | + - name: Upload Latest Version to S3 |
| 34 | + uses: jakejarvis/s3-sync-action@master |
| 35 | + with: |
| 36 | + args: --acl public-read --follow-symlinks --delete |
60 | 37 | env: |
61 | | - CI: true |
62 | | - GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |
63 | | - outputs: |
64 | | - pr_number: ${{ steps.get-pr-number.outputs.num }} |
65 | | - comment_body: ${{ steps.get-comment-body.outputs.body }} |
66 | | - steps: |
67 | | - - name: Get PR number |
68 | | - id: get-pr-number |
69 | | - run: echo "::set-output name=num::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" |
| 38 | + AWS_S3_BUCKET: ${{ secrets.AWS_DEV_BUCKET }} |
| 39 | + AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_KEY_ARTIFACTS }} |
| 40 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ARTIFACTS }} |
| 41 | + SOURCE_DIR: artifact/ |
| 42 | + DEST_DIR: ${{ github.event.pull_request.base.repo.name }}-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}/ |
| 43 | + |
| 44 | + comment-on-pr: |
| 45 | + name: Comment on PR with links to plugin ZIPs |
| 46 | + if: ${{ github.head_ref && github.head_ref != null && github.actor != 'dependabot[bot]' }} |
| 47 | + runs-on: ubuntu-latest |
| 48 | + needs: dev-zip |
| 49 | + env: |
| 50 | + CI: true |
| 51 | + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |
| 52 | + outputs: |
| 53 | + pr_number: ${{ steps.get-pr-number.outputs.num }} |
| 54 | + comment_body: ${{ steps.get-comment-body.outputs.body }} |
| 55 | + steps: |
| 56 | + - name: Get PR number |
| 57 | + id: get-pr-number |
| 58 | + run: echo "::set-output name=num::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" |
70 | 59 |
|
71 | | - - name: Check if a comment was already made |
72 | | - id: find-comment |
73 | | - uses: peter-evans/find-comment@v2 |
74 | | - with: |
75 | | - issue-number: ${{ steps.get-pr-number.outputs.num }} |
76 | | - comment-author: github-actions[bot] |
77 | | - body-includes: Download Plugin - [Download] |
| 60 | + - name: Check if a comment was already made |
| 61 | + id: find-comment |
| 62 | + uses: peter-evans/find-comment@v2 |
| 63 | + with: |
| 64 | + issue-number: ${{ steps.get-pr-number.outputs.num }} |
| 65 | + comment-author: github-actions[bot] |
| 66 | + body-includes: Download Plugin - [Download] |
78 | 67 |
|
79 | | - - name: Get comment body |
80 | | - id: get-comment-body |
81 | | - run: | |
82 | | - body="Plugin build for ${{ github.event.pull_request.head.sha }} is ready :bellhop_bell:! |
83 | | - - Download Plugin - [Download](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/hyve-lite.zip)" |
84 | | - body="${body//$'\n'/'%0A'}" |
85 | | - echo "::set-output name=body::$body" |
| 68 | + - name: Get comment body |
| 69 | + id: get-comment-body |
| 70 | + run: | |
| 71 | + body="Plugin build for ${{ github.event.pull_request.head.sha }} is ready :bellhop_bell:! |
| 72 | + - Download Plugin - [Download](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/hyve-lite.zip)" |
| 73 | + body="${body//$'\n'/'%0A'}" |
| 74 | + echo "::set-output name=body::$body" |
86 | 75 |
|
87 | | - - name: Create comment on PR with links to plugin builds |
88 | | - if: ${{ steps.find-comment.outputs.comment-id == '' }} |
89 | | - uses: peter-evans/create-or-update-comment@v2 |
90 | | - with: |
91 | | - issue-number: ${{ steps.get-pr-number.outputs.num }} |
92 | | - body: ${{ steps.get-comment-body.outputs.body }} |
| 76 | + - name: Create comment on PR with links to plugin builds |
| 77 | + if: ${{ steps.find-comment.outputs.comment-id == '' }} |
| 78 | + uses: peter-evans/create-or-update-comment@v2 |
| 79 | + with: |
| 80 | + issue-number: ${{ steps.get-pr-number.outputs.num }} |
| 81 | + body: ${{ steps.get-comment-body.outputs.body }} |
93 | 82 |
|
94 | | - - name: Update comment on PR with links to plugin builds |
95 | | - if: ${{ steps.find-comment.outputs.comment-id != '' }} |
96 | | - uses: peter-evans/create-or-update-comment@v2 |
97 | | - with: |
98 | | - comment-id: ${{ steps.find-comment.outputs.comment-id }} |
99 | | - edit-mode: replace |
100 | | - body: ${{ steps.get-comment-body.outputs.body }} |
| 83 | + - name: Update comment on PR with links to plugin builds |
| 84 | + if: ${{ steps.find-comment.outputs.comment-id != '' }} |
| 85 | + uses: peter-evans/create-or-update-comment@v2 |
| 86 | + with: |
| 87 | + comment-id: ${{ steps.find-comment.outputs.comment-id }} |
| 88 | + edit-mode: replace |
| 89 | + body: ${{ steps.get-comment-body.outputs.body }} |
0 commit comments