From 7a7db7e1beed83138fb18114736a9de6ce7a706c Mon Sep 17 00:00:00 2001 From: Andy Espagnolo Date: Wed, 17 Apr 2024 10:27:12 -0300 Subject: [PATCH] chore: add github worflows --- .github/workflows/audit.yml | 20 ++++++++ .github/workflows/build-release.yaml | 56 +++++++++++++++++++++++ .github/workflows/set-rollout-manual.yaml | 46 +++++++++++++++++++ .github/workflows/set-rollout.yaml | 30 ++++++++++++ .github/workflows/test.yaml | 17 +++++++ 5 files changed, 169 insertions(+) create mode 100644 .github/workflows/audit.yml create mode 100644 .github/workflows/build-release.yaml create mode 100644 .github/workflows/set-rollout-manual.yaml create mode 100644 .github/workflows/set-rollout.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 0000000..b942580 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,20 @@ +name: Audit + +on: [push, pull_request] + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Use Node.js 18.x + uses: actions/setup-node@v4.0.1 + with: + node-version: 18.x + cache: 'npm' + - name: Upgrade npm + run: npm i -g npm + - name: Install + run: npm ci --legacy-peer-deps + - name: Audit signatures + run: npm audit signatures diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml new file mode 100644 index 0000000..19fe6c7 --- /dev/null +++ b/.github/workflows/build-release.yaml @@ -0,0 +1,56 @@ +name: Build and release + +on: + push: + branches: + - main + release: + types: + - created + +jobs: + build-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Use Node.js 18.x + uses: actions/setup-node@v1 + with: + node-version: 18.x + - name: Set package.json version + uses: menduz/oddish-action@master + with: + deterministic-snapshot: true + only-update-versions: true + - name: Install + run: npm ci --legacy-peer-deps + env: + HUSKY: 0 + - name: Build + run: npm run build + env: + NODE_PATH: 'src' + NODE_OPTIONS: '--max-old-space-size=6144' + - name: Publish + uses: menduz/oddish-action@master + with: + cwd: './dist' + deterministic-snapshot: true + provenance: false + registry-url: 'https://registry.npmjs.org' + access: public + gitlab-token: ${{ secrets.GITLAB_CDN_DEPLOYER_TOKEN }} + gitlab-pipeline-url: ${{ secrets.GITLAB_CDN_DEPLOYER_URL }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Create Sentry release + if: github.event_name == 'release' && github.event.action == 'created' + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + with: + sourcemaps: ${{ github.workspace }}/dist + version: '${{ vars.SENTRY_RELEASE_PREFIX }}@${{ github.event.release.tag_name }}' + url_prefix: '~' diff --git a/.github/workflows/set-rollout-manual.yaml b/.github/workflows/set-rollout-manual.yaml new file mode 100644 index 0000000..ba9b20f --- /dev/null +++ b/.github/workflows/set-rollout-manual.yaml @@ -0,0 +1,46 @@ +name: Set rollout by path - Manual + +on: + workflow_dispatch: + inputs: + packageVersion: + description: "NPM Version of the release (@dcl/governance-site)" + required: true + default: "" + deploymentEnvironment: + type: "choice" + description: "Deployment environment" + required: true + default: "zone" + options: + - zone + - today + - org + rolloutPercentage: + description: "The percentage for this rollout" + required: true + default: "100" + +jobs: + set-manual-by-path-rollout: + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + - name: Set Rollout + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.ref }} + sha: ${{ github.sha }} + + # CDN information + packageName: "@dcl/governance-site" + packageVersion: ${{ github.event.inputs.packageVersion }} + + # Rollout information + deploymentPath: "governance" + deploymentEnvironment: ${{ github.event.inputs.deploymentEnvironment }} + deploymentName: "_site" + percentage: ${{ github.event.inputs.rolloutPercentage }} diff --git a/.github/workflows/set-rollout.yaml b/.github/workflows/set-rollout.yaml new file mode 100644 index 0000000..1d56632 --- /dev/null +++ b/.github/workflows/set-rollout.yaml @@ -0,0 +1,30 @@ +name: Set rollout by path + +on: [deployment_status] + +jobs: + set-rollout: + if: ${{ github.event.deployment.task == 'upload-to-cdn' && github.event.deployment_status.state == 'success' }} + runs-on: ubuntu-latest + steps: + - uses: hmarr/debug-action@v2 + + # Dev + - name: Set Rollout - Development + uses: decentraland/set-rollout-action@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + # Repo deployment info + ref: ${{ github.event.deployment.ref }} + sha: ${{ github.event.deployment.sha }} + + # CDN information + packageName: ${{ github.event.deployment.payload.packageName }} + packageVersion: ${{ github.event.deployment.payload.packageVersion }} + + # Rollout information + deploymentPath: 'governance' + deploymentEnvironment: 'zone' + deploymentName: '_site' + percentage: 100 \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..4654aee --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,17 @@ +name: Test + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Use Node.js 18.x + uses: actions/setup-node@v1 + with: + node-version: 18.x + - name: Install + run: npm ci --legacy-peer-deps + - name: Test + run: npm run test \ No newline at end of file