-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
647 additions
and
13 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
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
61 changes: 61 additions & 0 deletions
61
.github/workflows/automation-tests-on-repository-dispatch-new.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,61 @@ | ||
name: NEW Execute automation tests | ||
run-name: Run tests on ${{github.event.client_payload.custom_version }} ${{github.event.client_payload.project}} | ||
|
||
on: | ||
repository_dispatch: | ||
types: [automation-tests-event] | ||
|
||
jobs: | ||
get-environment-variables: | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 30 | ||
outputs: | ||
VERSION: ${{ steps.get-environment-variables.outputs.version }} | ||
env: | ||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
CUSTOM_VERSION: ${{github.event.client_payload.custom_version }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd .github/workflows | ||
npm ci | ||
- name: get environment variables | ||
id: get-environment-variables | ||
run: | | ||
node .github/workflows/getEnvironmentVariables.js \ | ||
--custom_version "$CUSTOM_VERSION" \ | ||
--repo_token "$REPO_TOKEN" | ||
run-tests-on-release: | ||
needs: get-environment-variables | ||
uses: ./.github/workflows/run-tests-on-release-new.yml | ||
with: | ||
VERSION: ${{needs.get-environment-variables.outputs.VERSION}} | ||
CUSTOM_VERSION: ${{github.event.client_payload.custom_version }} | ||
ADDITIONAL_TITLE: "Core automation test" | ||
secrets: inherit | ||
|
||
add-comment-to-release-pr: | ||
if: ${{ !cancelled() }} | ||
needs: run-tests-on-release | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: add-comment-to-release-pr | ||
env: | ||
PR_NUMBER: ${{github.event.client_payload.release_pr }} | ||
PR_COMMENT: ${{needs.run-tests-on-release.outputs.PR_COMMENT}} | ||
run: | | ||
export GITHUB_TOKEN=$( \ | ||
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ | ||
) | ||
gh pr comment "$PR_NUMBER" --body "$PR_COMMENT" -R github.com/saleor/saleor-cloud-deployments | ||
186 changes: 186 additions & 0 deletions
186
.github/workflows/deploy-staging-and-prepare-release-new.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,186 @@ | ||
name: NEW 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: | ||
## backward compatibility for older versions | ||
APPS_MARKETPLACE_API_URI: "https://apps.staging.saleor.io/api/v2/saleor-apps" | ||
## backward compatibility for older versions | ||
API_URI: /graphql/ | ||
|
||
API_URL: /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_URL: "https://apps.staging.saleor.io/api/v2/saleor-apps" | ||
VERSION: ${{ github.event.inputs.git_ref || github.ref_name }} | ||
IS_CLOUD_INSTANCE: true | ||
ENABLED_SERVICE_NAME_HEADER: true | ||
ONBOARDING_USER_JOINED_DATE_THRESHOLD: ${{ vars.STAGING_ONBOARDING_USER_JOINED_DATE_THRESHOLD }} | ||
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: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_CLOUD_STAGING_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_CLOUD_STAGING_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Deploy | ||
id: deploy | ||
run: | | ||
aws s3 sync build/dashboard "s3://${DEPLOYMENT_BUCKET}/${ENVIRONMENT}/static/" | ||
aws s3 cp build/dashboard/index.html "s3://${DEPLOYMENT_BUCKET}/${ENVIRONMENT}/" | ||
IFS=',' read -ra DISTRIBUTIONS_ARRAY <<< "${CDN_DISTRIBUTIONS}" | ||
for DISTRIBUTION in "${DISTRIBUTIONS_ARRAY[@]}"; do | ||
echo "::add-mask::$DISTRIBUTION" | ||
for i in {1..3}; do aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "/dashboard*" && break || sleep 5; done | ||
done | ||
env: | ||
DEPLOYMENT_BUCKET: ${{ secrets.AWS_CLOUD_STAGING_DEPLOYMENT_BUCKET }} | ||
CDN_DISTRIBUTIONS: ${{ secrets.AWS_CLOUD_STAGING_CDN_DISTRIBUTIONS }} | ||
|
||
- 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: "completed" | ||
CONCLUSION: "${{ steps.deploy.outcome }}" | ||
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 }}" | ||
|
||
- name: Notify Slack | ||
if: ${{ always() }} | ||
env: | ||
JOB_DEPLOYMENT_KIND: staging | ||
JOB_STATUS: ${{ job.status }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CLOUD_DEPLOYMENTS_WEBHOOK_URL }} | ||
SLACK_MENTION_GROUP_ID: ${{ secrets.SLACK_DASHBOARD_GROUP_ID }} | ||
JOB_TITLE: "Dashboard deployment of ${{ env.CUSTOM_VERSION || env.VERSION }} to ${{ env.ENVIRONMENT }}" | ||
run: | | ||
python3 ./.github/workflows/notify/notify-slack.py | ||
- name: Prepare Sandbox release pull request | ||
if: needs.prepare-release.outputs.hasChangesets == 'false' | ||
run: | | ||
export GITHUB_TOKEN=$( \ | ||
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \ | ||
) | ||
version=$(cat package.json | jq -r .version) | ||
payload=$(jq --null-input --arg version "$version" '{ | ||
"event_type": "open-release-pull-request", | ||
"client_payload": { | ||
"project": "DASHBOARD", | ||
"environment": "SANDBOX", | ||
"version": $version | ||
} | ||
}') | ||
gh api /repos/saleor/saleor-cloud-deployments/dispatches --input - <<< $payload | ||
run-tests-on-release: | ||
needs: [prepare-release, build] | ||
if: needs.prepare-release.outputs.hasChangesets == 'true' | ||
uses: ./.github/workflows/run-tests-on-release-new.yml | ||
with: | ||
VERSION: ${{ needs.build.outputs.MINOR_VERSION }} # eg. "3.19" | ||
CUSTOM_VERSION: ${{ needs.build.outputs.CUSTOM_VERSION }} # eg. "3.19.4-5a41d18" | ||
secrets: inherit |
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
Oops, something went wrong.