From 4278e6863b8d0e686f4f6dc8b1d186a9daae1997 Mon Sep 17 00:00:00 2001 From: Aatman Vaidya Date: Wed, 20 Sep 2023 12:44:51 +0530 Subject: [PATCH] feat: github actions to build browser extension for pull requests (#373) Builds the extension for firefox and chrome and adds a link to them under the PR comments section. --- .../build-pr-review-both-browsers.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/build-pr-review-both-browsers.yml diff --git a/.github/workflows/build-pr-review-both-browsers.yml b/.github/workflows/build-pr-review-both-browsers.yml new file mode 100644 index 00000000..522f75c3 --- /dev/null +++ b/.github/workflows/build-pr-review-both-browsers.yml @@ -0,0 +1,54 @@ +name: "Build For PR Review - Both Browsers" + +on: + pull_request: + branches: + - main + +jobs: + chrome-publish: + name: "Build For PR Review" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout Development Branch" + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Get commit SHA + shell: bash + run: | + echo "setting variables" + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: "Build and Test" + run: | + cd browser-extension/plugin + ls + pwd + npm install + npm run build + mv dist/ extension-chrome/ + npm run build:firefox + mv dist/ extension-firefox/ + - name: "Upload dist folder as artifact" + uses: actions/upload-artifact@v3 + with: + name: extension-artifcats + path: | + browser-extension/plugin/extension-firefox/ + browser-extension/plugin/extension-chrome/ + + - name: Create PR Comment with Artifact Link + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const artifact_url = `https://github.com/${{github.repository_owner}}/${{github.event.repository.name}}/actions/runs/${{ github.run_id }}`; + const comment_body = `🛠 Your build files are available [here](${artifact_url}).`; + await github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment_body + }); \ No newline at end of file