diff --git a/.circleci/config.yml b/.circleci/config.yml index a0bd915..63a9b86 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -135,18 +135,18 @@ workflows: name: build requires: - setup - - deploy-lookaside-gcs: - <<: *dev - name: deploy-lookaside-gcs - context: - - core-dev - requires: - - setup - - build + # - deploy-lookaside-gcs: + # <<: *dev + # name: deploy-lookaside-gcs + # context: + # - core-dev + # requires: + # - setup + # - build - pr-comment: <<: *dev name: pr-comment context: core-dev - requires: - - deploy-lookaside-gcs + # requires: + # - deploy-lookaside-gcs diff --git a/.github/workflows/lookaside.yml b/.github/workflows/lookaside.yml new file mode 100644 index 0000000..6e2c745 --- /dev/null +++ b/.github/workflows/lookaside.yml @@ -0,0 +1,56 @@ +name: GCS Lookaside + +on: + push: + branches-ignore: + - main + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + - name: Prepare npmrc + run: envsubst < ci.npmrc > .npmrc + env: + ARTIFACTORY_TOKEN: '${{ secrets.ARTIFACTORY_TOKEN }}' + - name: Install dependencies + uses: bahmutov/npm-install@v1 + - name: Build project + run: npm run build + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + path: dist + + # Deployment job + deploy: + environment: + name: google-cloud-storage + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + - name: Download artifact + uses: actions/download-artifact@v4 + with: + path: dist + - name: Add service key + run: echo ${{ secrets.GCLOUD_SERVICE_KEY }} > "gcloud-service-key.json" + - name: Deploy to Google Cloud Storage + id: deployment + run: node scripts/lookaside.mjs --keyFilename=gcloud-service-key.json --branch ${{ github.ref_name }} diff --git a/scripts/lookaside.mjs b/scripts/lookaside.mjs index 7e6482e..d7f6422 100644 --- a/scripts/lookaside.mjs +++ b/scripts/lookaside.mjs @@ -45,6 +45,7 @@ async function run() { await Promise.all(uploads); console.log(logSymbols.success, 'Lookaside deployed'); + process.env.GITHUB_OUTPUT = `page_url=https://storage.googleapis.com/prism-design-system/${branch}/index.html`; } catch (error) { console.log(logSymbols.error, error); process.exit(1);