fix: use dag-staging gateway from staging api (#2318) #2560
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: API | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'packages/api/**' | |
- 'packages/db/**' | |
- '.github/workflows/api.yml' | |
- 'package-lock.json' | |
pull_request: | |
paths: | |
- 'packages/api/**' | |
- 'packages/db/**' | |
- '.github/workflows/api.yml' | |
- 'package-lock.json' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
name: Test | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: microsoft/playwright-github-action@v1 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- uses: bahmutov/npm-install@v1 | |
- run: npm run build --workspace packages/api | |
- run: npm test --workspace packages/api | |
env: | |
PG_REST_URL: ${{secrets.PG_REST_URL}} | |
PG_REST_JWT: ${{secrets.PG_REST_JWT}} | |
PG_CONNECTION: ${{secrets.PG_CONNECTION}} | |
changelog: | |
name: Changelog | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: test | |
outputs: | |
releases_created: ${{ steps.tag-release.outputs.releases_created }} | |
steps: | |
- uses: GoogleCloudPlatform/release-please-action@v3 | |
id: tag-release | |
with: | |
path: packages/api | |
token: ${{ secrets.GITHUB_TOKEN }} | |
release-type: node | |
monorepo-tags: true | |
package-name: api | |
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Other Changes","hidden":false}]' | |
deploy-staging: | |
name: Deploy Staging | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- uses: bahmutov/npm-install@v1 | |
- name: Publish api worker | |
uses: cloudflare/[email protected] | |
env: | |
ENV: 'staging' # inform the build process what the env is | |
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN}} | |
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD}} | |
with: | |
apiToken: ${{ secrets.CF_TOKEN }} | |
workingDirectory: 'packages/api' | |
environment: 'staging' | |
- name: Test upload to staging | |
run: | | |
npm run build -w packages/client | |
echo "$(date --utc --iso-8601=seconds) web3.storage upload test" > ./upload-test-small | |
./packages/w3/bin.js put ./upload-test-small --api https://api-staging.web3.storage --token ${{ secrets.STAGING_WEB3_TOKEN }} | |
deploy-production: | |
name: Deploy Production | |
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changelog.outputs.releases_created) || inputs.force_release | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- changelog | |
environment: | |
name: production | |
url: https://web3.storage | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org/ | |
- uses: bahmutov/npm-install@v1 | |
- name: API - Deploy to Cloudflare | |
uses: cloudflare/[email protected] | |
env: | |
ENV: 'production' # inform the build process what the env is | |
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN}} | |
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD}} | |
with: | |
apiToken: ${{ secrets.CF_TOKEN }} | |
workingDirectory: 'packages/api' | |
environment: 'production' |