Skip to content

SPDE-130: Re-CD this repo #18

SPDE-130: Re-CD this repo

SPDE-130: Re-CD this repo #18

name: New Pull request; publish as beta package
on:
pull_request:
branches: [ "master" ]
env:
NPM_REGISTRY_URL: "https://www.npmjs.com/package/hellosign-embedded"
BETA_SUFFIX: 'testbeta'
CDN_AWS_PUBLISH_ROLE: arn:aws:iam::654344198836:role/github-actions-oidc-role-nonprod-sign-embedded
CDN_PUBLISH_LOCATION: s3://cdn.staging-hellosign.com/test/js/embedded/
AWS_REGION: us-east-1
jobs:
build:
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for publishing releases
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x] # we should pull this from a common place
steps:
- uses: actions/checkout@v3
- name: Extract version from package.json
uses: sergeysova/jq-action@v2
id: version
with:
cmd: 'jq .version package.json -r'
- name: Check existing releases
uses: cardinalby/git-get-release-action@v1
id: released
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: "v${{ steps.version.outputs.value }}"
doNotFailIfNotFound: true
- name: Block if found
if: "${{ steps.released.outputs.id }}"
run: |
echo "v${{ steps.version.outputs.value }} has already been released, update project version in package.json to produce beta package."
exit 1
- name: Check beta releases
uses: cardinalby/git-get-release-action@v1
id: beta-released
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: "v${{ steps.version.outputs.value }}-${{ env.BETA_SUFFIX }}"
doNotFailIfNotFound: true
- name: Alert if found
if: "${{ steps.beta-released.outputs.id }}"
run: |
echo "v${{ steps.version.outputs.value }}-${{ env.BETA_SUFFIX }} exists and will be overwritten."
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# registry-url: ${{ env.NPM_REGISTRY_URL }}
# always-auth: true
# token:
- name: Build
run: |
npm install
npm run build
- name: Test
run: |
npm test
- name: Testing Release
env:
GITHUB_TOKEN: ${{ github.token }}
uses: ncipollo/release-action@v1
with:
artifacts: "umd/*.js"
tag: "v${{ steps.version.outputs.value }}-${{ env.BETA_SUFFIX }}"
allowUpdates: true
draft: true
generateReleaseNotes: true
makeLatest: false
prerelease: true
- name: Configure AWS credentials for Non-Prod
id: awskeys
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CDN_AWS_PUBLISH_ROLE }}
aws-region: ${{ env.AWS_REGION }}
- name: Upload folder to bucket
uses: a-sync/s3-uploader@master
with:
args: --exclude "*" --include "embedded.*.js"
env:
# AWS_ACCESS_KEY_ID: ${{ steps.awskeys.outputs.aws-access-key-id }}
# AWS_SECRET_ACCESS_KEY: ${{ steps.awskeys.outputs.aws-access-key-id }}
# AWS_REGION: ${{ env.AWS_REGION }}
S3_BUCKET: 'cdn.staging-hellosign.com'
S3_KEY: 'test/js/embedded/'
FILE: ./umd
# - name: List files to test locations
# run: aws s3 ls ${{ env.CDN_PUBLISH_LOCATION }}
#
# - name: Copy files to test locations
# run: aws s3 cp umd/ ${{ env.CDN_PUBLISH_LOCATION }} --exclude "*" --include "*.js"