From a18fd4d35e8366e5784c35069652b96b35333012 Mon Sep 17 00:00:00 2001 From: AlexanderBelokon Date: Mon, 6 Jan 2025 16:57:16 +0200 Subject: [PATCH 1/3] Migrate to GHA from publisher --- .artifacts.yml | 9 ------- .github/workflows/basic.yml | 31 +++++++++++++++++++++ .github/workflows/deploy.yml | 52 ++++++++++++++++++++++++++++++++++++ .prettierignore | 1 - 4 files changed, 83 insertions(+), 10 deletions(-) delete mode 100644 .artifacts.yml create mode 100644 .github/workflows/basic.yml create mode 100644 .github/workflows/deploy.yml delete mode 120000 .prettierignore diff --git a/.artifacts.yml b/.artifacts.yml deleted file mode 100644 index 728ae656..00000000 --- a/.artifacts.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: v1 -publisher: - builds: - - filter: on-branch - name: publisher-branches - config: - node_version: 14.x - site_build_dir: _site - npm_build_script: build diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml new file mode 100644 index 00000000..4c08c94a --- /dev/null +++ b/.github/workflows/basic.yml @@ -0,0 +1,31 @@ +name: Basic Tests + +on: + pull_request: + +jobs: + prepare: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - name: Configure AWS Credentials + uses: mapbox/configure-aws-credentials-internal@v5 + with: + target-account-id: ${{ vars.AWS_ACCOUNT_ID_DEFAULT }} + + - name: Retrieve and configure npm token + uses: mapbox/setup-npm-token@v2 + + - name: Install npm dependencies + run: npm ci --no-fund --no-audit --prefer-offline + + - name: Test + run: npm test diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..cfc5399f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: Deploy + +on: + push: + branches: [staging, production] + +env: + bucket: '{ "staging": "labs.mapbox.com-staging/assembly", "production": "labs.mapbox.com/assembly" }' + +jobs: + deploy: + name: Deploy to ${{ matrix.environment }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + strategy: + matrix: + environment: [staging, production] + exclude: + - environment: ${{ github.ref_name != 'staging' && 'staging' }} + - environment: ${{ github.ref_name != 'production' && 'production' }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - name: Configure AWS Credentials + uses: mapbox/configure-aws-credentials-internal@v5 + with: + target-account-id: ${{ vars.AWS_ACCOUNT_ID_DEFAULT }} + + - name: Retrieve and configure npm token + uses: mapbox/setup-npm-token@v2 + + - name: Install npm dependencies + run: npm ci --no-fund --no-audit --prefer-offline + + - name: Build for ${{ matrix.environment }} + run: npm run build + + - name: Sync files ${{ matrix.environment }} + run: aws s3 sync _site ${{ env.targetBucket }} --exclude "*.html" --exclude "*.xml" --cache-control "max-age=31536000" + env: + targetBucket: s3://${{ fromJson(env.bucket)[matrix.environment] }} + + - name: Sync html files to ${{ matrix.environment }} + run: aws s3 sync _site ${{ env.targetBucket }} --exclude "*" --include "*.html" --include "*.xml" --cache-control "max-age=10,stale-while-revalidate=60" + env: + targetBucket: s3://${{ fromJson(env.bucket)[matrix.environment] }} diff --git a/.prettierignore b/.prettierignore deleted file mode 120000 index f62e2b43..00000000 --- a/.prettierignore +++ /dev/null @@ -1 +0,0 @@ -.eslintignore \ No newline at end of file From 22275a5877f4ebe237f292721248d87ffee34290 Mon Sep 17 00:00:00 2001 From: AlexanderBelokon Date: Mon, 6 Jan 2025 22:32:39 +0200 Subject: [PATCH 2/3] Remove publisher --- .publisher.yml | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .publisher.yml diff --git a/.publisher.yml b/.publisher.yml deleted file mode 100644 index f2b5b4af..00000000 --- a/.publisher.yml +++ /dev/null @@ -1 +0,0 @@ -subdomain: labs From eb068702d76104a3905bbd6333365d169fbdb5d7 Mon Sep 17 00:00:00 2001 From: AlexanderBelokon Date: Mon, 6 Jan 2025 22:32:50 +0200 Subject: [PATCH 3/3] Rename workflow --- .github/workflows/basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 4c08c94a..3ed8383f 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -4,7 +4,7 @@ on: pull_request: jobs: - prepare: + test: runs-on: ubuntu-latest permissions: id-token: write