Skip to content

Commit

Permalink
feat: add publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
braianj committed May 8, 2024
1 parent c35de2e commit bbd40d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 93 deletions.
114 changes: 21 additions & 93 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,24 @@
on:
workflow_call:
inputs:
run-pre-publish:
required: false
type: boolean
default: false
secrets:
SDK_TEAM_S3_BASE_URL:
required: true
SDK_TEAM_S3_BUCKET:
required: true
SDK_TEAM_AWS_REGION:
required: true
GITLAB_TOKEN:
required: true
GITLAB_URL:
required: true
NPM_TOKEN:
required: true
SDK_TEAM_AWS_ID:
required: true
SDK_TEAM_AWS_SECRET:
required: true

name: build-publish
jobs:
check_and_build:
runs-on: ubuntu-latest
permissions:
id-token: write
outputs:
s3_bucket_key: ${{ steps.publish_package.outputs.s3-bucket-key }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Prettier check
run: npm run format
- name: Check linting
run: npm run lint
- name: Build library
run: npm run build
- name: publish packages
uses: menduz/oddish-action@master
id: publish_package
with:
registry-url: "https://registry.npmjs.org"
access: public
## use action runId instead of current date to generate snapshot numbers
deterministic-snapshot: true

## publish every package to s3
s3-bucket: ${{ secrets.SDK_TEAM_S3_BUCKET }}
s3-bucket-key-prefix: "@dcl/${{ github.event.repository.name }}/branch/${{ github.head_ref }}"
s3-bucket-region: ${{ secrets.SDK_TEAM_AWS_REGION }}
name: build and publish

## inform gitlab after publishing to proceed with CDN propagation
gitlab-token: ${{ secrets.GITLAB_TOKEN }}
gitlab-pipeline-url: ${{ secrets.GITLAB_URL }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}

notify_deployment:
needs: [check_and_build]
if: ${{ github.event.pull_request.number && !startsWith(github.head_ref, 'dependabot/') }}
runs-on: ubuntu-latest
name: Deployment Notification
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Test this pull request
on:
push:
branches:
- main
pull_request:
release:
types:
- created

- name: Generate S3 URL
id: url-generator
run: echo "body=${{ secrets.SDK_TEAM_S3_BASE_URL }}/${{ needs.check_and_build.outputs.s3_bucket_key }}" >> $GITHUB_OUTPUT

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# Test this pull request
- The package can be tested by running
```bash
npm i "${{ steps.url-generator.outputs.body }}"
```
edit-mode: replace
jobs:
build-publish:
uses: decentraland/platform-actions/.github/workflows/libs-build-and-publish.yml@main
secrets:
SDK_TEAM_S3_BUCKET: ${{ secrets.SDK_TEAM_S3_BUCKET }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_URL: ${{ secrets.GITLAB_URL }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
SDK_TEAM_AWS_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
SDK_TEAM_AWS_SECRET: ${{ secrets.SDK_TEAM_AWS_SECRET }}
SDK_TEAM_S3_BASE_URL: ${{ secrets.SDK_TEAM_S3_BASE_URL }}
SDK_TEAM_AWS_REGION: ${{ secrets.SDK_TEAM_AWS_REGION }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build-storybook": "npm run generate:storybooks && npx storybook@7 build",
"format": "prettier --write '**/*.{ts,tsx,js,jsx,json,md,mdx,css}'",
"lint": "eslint --ext .ts,.tsx,.js,.jsx ./src",
"lint:check": "eslint --ext .ts,.tsx,.js,.jsx ./src",
"lint:fix": "npm run lint -- --fix",
"generate:storybooks": "ts-node ./bin/storybookGenerator.ts && npm run lint:fix"
},
Expand Down

0 comments on commit bbd40d9

Please sign in to comment.