forked from saleor/saleor-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from karola312/release-test
Release test
- Loading branch information
Showing
11 changed files
with
587 additions
and
258 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"saleor-dashboard": patch | ||
--- | ||
|
||
release |
77 changes: 77 additions & 0 deletions
77
.github/actions/checks/create-pull-request-check/action.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Create-check | ||
description: "Creates check for PR" | ||
inputs: | ||
PR_HEAD: | ||
description: "Head of PR on which create check" | ||
required: true | ||
CHECK_NAME: | ||
description: "Name of check" | ||
required: true | ||
STATUS: | ||
description: "Status of check" | ||
required: true | ||
TITLE: | ||
description: "Title of check" | ||
required: true | ||
DETAILS_URL: | ||
description: "Details url" | ||
required: true | ||
|
||
outputs: | ||
CHECK_ID: | ||
description: "CHECK_ID" | ||
value: ${{ steps.create-check.outputs.check_id }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get Pull Request head_sha | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
PR_HEAD: ${{ inputs.PR_HEAD }} | ||
run: | | ||
gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"/repos/saleor/saleor-dashboard/pulls?head=saleor:${PR_HEAD}" > data.json | ||
head_sha_with_quotes=$(jq '.[0] | .head.sha' data.json) | ||
echo "PULL_REQUEST_HEAD_SHA=${head_sha_with_quotes//\"/}" >> "$GITHUB_ENV" | ||
- name: Create check | ||
if: ${{ env.PULL_REQUEST_HEAD_SHA }} | ||
shell: bash | ||
id: create-check | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
NAME: ${{ inputs.CHECK_NAME }} | ||
STATUS: ${{ inputs.STATUS }} | ||
TITLE: ${{ inputs.TITLE }} | ||
run: | | ||
payload=$(\ | ||
jq --null-input \ | ||
--arg name "$NAME" \ | ||
--arg head_sha "$PULL_REQUEST_HEAD_SHA" \ | ||
--arg status "$STATUS" \ | ||
--arg title "$TITLE" \ | ||
--arg details_url "$DETAILS_URL" \ | ||
'{ | ||
"name": $name, | ||
"head_sha": $head_sha, | ||
"status": $status, | ||
"output": { | ||
"title": $title, | ||
"summary": "", | ||
"text": "", | ||
"details_url": $details_url | ||
} | ||
}' | ||
) | ||
check_id=$(curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GH_TOKEN" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/saleor/saleor-dashboard/check-runs \ | ||
-d "$payload" | jq -r '.id') ; echo "check_id=$check_id" >> "$GITHUB_OUTPUT" |
69 changes: 69 additions & 0 deletions
69
.github/actions/checks/update-pull-request-check/action.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Create-check | ||
description: "Creates check for PR" | ||
inputs: | ||
CHECK_ID: | ||
description: "Check id" | ||
required: true | ||
CHECK_NAME: | ||
description: "Name of check - must be the same here and in create check" | ||
required: true | ||
STATUS: | ||
description: "Status of check" | ||
required: true | ||
CONCLUSION: | ||
description: "Conclusion of check, required if status completed" | ||
required: false | ||
TITLE: | ||
description: "Title of check" | ||
required: true | ||
SUMMARY: | ||
description: "Summary of check" | ||
required: true | ||
DETAILS_URL: | ||
description: "Url with details to check" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Update check | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
CHECK_ID: ${{ inputs.CHECK_ID }} | ||
NAME: ${{ inputs.CHECK_NAME }} | ||
STATUS: ${{ inputs.STATUS }} | ||
CONCLUSION: ${{inputs.CONCLUSION}} | ||
TITLE: ${{ inputs.TITLE }} | ||
SUMMARY: ${{ inputs.SUMMARY }} | ||
DETAILS_URL: ${{ inputs.DETAILS_URL }} | ||
run: | | ||
payload=$(\ | ||
jq --null-input \ | ||
--arg name "$NAME" \ | ||
--arg status "$STATUS" \ | ||
--arg conclusion "$CONCLUSION" \ | ||
--arg title "$TITLE" \ | ||
--arg summary "$SUMMARY" \ | ||
--arg details_url "$DETAILS_URL" \ | ||
'{ | ||
"name": $name, | ||
"status": $status, | ||
"conclusion": $conclusion, | ||
"output": { | ||
"title": $title, | ||
"summary": $summary, | ||
"text": "", | ||
"details_url": $details_url | ||
} | ||
}' | ||
) | ||
curl -L \ | ||
-X PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GH_TOKEN" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"https://api.github.com/repos/saleor/saleor-dashboard/check-runs/$CHECK_ID" \ | ||
-d "$payload" |
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
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
130 changes: 130 additions & 0 deletions
130
.github/workflows/deploy-staging-and-prepare-release.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
name: Deploy Dashboard to staging | ||
on: | ||
push: | ||
branches: | ||
# Matches release branches | ||
- "[0-9]+.[0-9]+" | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
prepare-release: | ||
name: Prepare release with Changesets | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
- name: Install Dependencies | ||
run: npm ci | ||
- name: Publishing version | ||
uses: changesets/action@d89c1de63c7f28ac47ec85ed395f5f1d045d4697 # v1.4.4 | ||
id: changesets | ||
with: | ||
title: "Prepare release ${{ github.ref_name }}" | ||
commit: "Release ${{ github.ref_name }}" | ||
publish: "npm run release" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
build: | ||
needs: prepare-release | ||
if: always() | ||
runs-on: ubuntu-20.04 | ||
outputs: | ||
MINOR_VERSION: ${{ env.MINOR_VERSION }} | ||
CUSTOM_VERSION: ${{ env.CUSTOM_VERSION || env.VERSION }} | ||
env: | ||
API_URI: /graphql/ | ||
APP_MOUNT_URI: /dashboard/ | ||
STATIC_URL: /dashboard/static/ | ||
SENTRY_ORG: saleor | ||
SENTRY_PROJECT: dashboard | ||
SENTRY_URL_PREFIX: "~/dashboard/static" | ||
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: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.VERSION }} | ||
|
||
- name: Set environment | ||
# Convert version into staging deployment name (e.g 3.3.0 -> saleor-staging-v33) | ||
run: | | ||
set -x | ||
environment=$(echo $VERSION | sed -n 's#\([0-9]\+\).\([0-9]\+\).*#saleor-staging-v\1\2#p') | ||
echo "ENVIRONMENT=${environment}" >> "$GITHUB_ENV" | ||
- name: Set custom version | ||
env: | ||
VERSION: ${{ github.event.inputs.git_ref || github.ref_name }} | ||
# Add commit hash to basic version number | ||
run: | | ||
set -x | ||
HASH=$(git rev-parse --short HEAD) | ||
CURRENT_VERSION=$(jq -r .version package.json) | ||
RELEASE="${CURRENT_VERSION}-${HASH}" | ||
echo "CUSTOM_VERSION=${RELEASE}" >> "$GITHUB_ENV" | ||
echo "SENTRY_RELEASE=${RELEASE}" >> "$GITHUB_ENV" | ||
minor_version=$(echo "$VERSION" | sed -n 's#\([0-9]\+\).\([0-9]\+\).*#\1.\2#p') | ||
echo "MINOR_VERSION=${minor_version}" >> "$GITHUB_ENV" | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
|
||
- name: Create check in prepare release PR | ||
if: needs.prepare-release.outputs.hasChangesets == 'true' | ||
id: create-check | ||
uses: ./.github/actions/checks/create-pull-request-check | ||
with: | ||
PR_HEAD: "changeset-release/${{env.MINOR_VERSION}}" | ||
CHECK_NAME: "Deploy_staging" | ||
STATUS: "in_progress" | ||
TITLE: "Deploy staging" | ||
DETAILS_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
|
||
- name: Package | ||
timeout-minutes: 15 | ||
run: | | ||
npm ci | ||
- name: Build | ||
run: | | ||
npm run build | ||
- name: Deploy | ||
id: deploy | ||
run: | | ||
echo "Deploying..." | ||
- name: Update check | ||
if: always() && ${{ steps.create-check.outputs.CHECK_ID }} | ||
uses: ./.github/actions/checks/update-pull-request-check | ||
with: | ||
CHECK_ID: ${{ steps.create-check.outputs.CHECK_ID }} | ||
CHECK_NAME: "Deploy_staging" | ||
STATUS: "${{ steps.deploy.outcome }}" | ||
CONCLUSION: "${{ steps.deploy.conclusion }}" | ||
TITLE: "Deploy staging" | ||
SUMMARY: "Deploy finished with status ${{ steps.deploy.outcome }}. To check details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
DETAILS_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
|
||
run-tests-on-release: | ||
needs: [prepare-release, build] | ||
if: needs.prepare-release.outputs.hasChangesets == 'true' | ||
uses: ./.github/workflows/run-tests-on-release.yml | ||
with: | ||
VERSION: ${{ needs.build.MINOR_VERSION }} # eg. "3.19" | ||
CUSTOM_VERSION: ${{ needs.build.CUSTOM_VERSION }} # eg. "3.19.4-5a41d18" | ||
secrets: inherit |
Oops, something went wrong.