diff --git a/.changeset/unlucky-ties-jam.md b/.changeset/unlucky-ties-jam.md new file mode 100644 index 00000000000..7871889fc84 --- /dev/null +++ b/.changeset/unlucky-ties-jam.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Update workflow to be compatible with changesets diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 96cc38d8f35..7ce7d40adf0 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -9,9 +9,11 @@ on: concurrency: ${{ github.workflow }}-${{ github.ref }} jobs: - release: + prepare: name: Prepare release with Changesets - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + outputs: + published: ${{ steps.changesets.outputs.published }} permissions: contents: write pull-requests: write @@ -24,7 +26,7 @@ jobs: node-version-file: ".nvmrc" - name: Install Dependencies run: npm ci - - name: Create Release Pull Request + - name: Publishing version uses: changesets/action@d89c1de63c7f28ac47ec85ed395f5f1d045d4697 # v1.4.4 id: changesets with: @@ -33,3 +35,58 @@ jobs: publish: "npm run release" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + name: Deploy and release to sandbox + needs: changesets + if: needs.prepare.outputs.published == 'true' + runs-on: ubuntu-22.04 + env: + API_URI: /graphql/ + APP_MOUNT_URI: /dashboard/ + STATIC_URL: /dashboard/static/ + SENTRY_ORG: saleor + SENTRY_PROJECT: dashboard + SENTRY_URL_PREFIX: "~/dashboard/static" + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps" + VERSION: ${{ github.event.inputs.git_ref || github.ref_name }} + IS_CLOUD_INSTANCE: true + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + - name: Install Dependencies + run: npm ci + - name: Build + run: | + npm run build + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_DASHBOARD_STAGING_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DASHBOARD_STAGING_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Deploy + run: | + aws s3 sync build/dashboard s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/static/ + aws s3 cp build/dashboard/index.html s3://${{ secrets.AWS_STAGING_DEPLOYMENT_BUCKET }}/${ENVIRONMENT}/ + for i in {1..3}; do aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_STAGING_CF_DIST_ID }} --paths "/dashboard*" && break || sleep 5; done + - name: Prepare Sandbox release pull request + run: | + export GITHUB_TOKEN=$( \ + curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ + ) + gh api /repos/saleor/saleor-cloud-deployments/dispatches \ + --input - <<< '{ + "event_type": "open-release-pull-request", + "client_payload": { + "project": "DASHBOARD", + "environment": "SANDBOX", + "version": "${{ github.ref_name }}" + } + }' \ No newline at end of file