diff --git a/.github/actions/check_if_latest_release/action.yml b/.github/actions/check_if_latest_release/action.yml new file mode 100644 index 0000000000..10006447bb --- /dev/null +++ b/.github/actions/check_if_latest_release/action.yml @@ -0,0 +1,26 @@ +name: check_if_latest_release +inputs: + token: + description: "Github API token" +runs: + using: composite + steps: + - name: Check if latest release + run: |- + RELEASE_JSON=$(curl -s -H "Authorization: token ${{ inputs.token }}" \ + "https://api.github.com/repos/${{ github.repository }}/releases/latest") + + LATEST_TAG_NAME=$(echo "$RELEASE_JSON" | jq -r '.tag_name') + RELEASE_EVENT_TAG_NAME=$(echo ${{ github.event.release.tag_name }}) + + echo "Latest tag: $LATEST_TAG_NAME" + echo "Release event tag: $RELEASE_EVENT_TAG_NAME" + + if [ "$LATEST_TAG_NAME" == "$RELEASE_EVENT_TAG_NAME" ]; then + echo "We are releasing the latest tag. Continuing deployment workflow." + exit 0 + else + echo "We are not releasing the latest tag. Stopping deployment workflow." + exit 1 + fi + shell: bash \ No newline at end of file diff --git a/.github/actions/push_to_mrt/action.yml b/.github/actions/push_to_mrt/action.yml index ec18ed1e93..bce90ddc13 100644 --- a/.github/actions/push_to_mrt/action.yml +++ b/.github/actions/push_to_mrt/action.yml @@ -4,18 +4,22 @@ inputs: description: Project directory default: ${{ github.workspace }} TARGET: - description: MRT target + description: MRT target environment FLAGS: description: Push flags + PROJECT: + description: MRT target project + default: "scaffold-pwa" + MESSAGE: + description: Bundle message / name + default: "build ${{ github.run_id }} on ${{ github.ref }} (${{ github.sha }})" runs: using: composite steps: - name: Push Bundle to MRT run: |- cd ${{ inputs.CWD }} - project="scaffold-pwa" - build="build ${{ github.run_id }} on ${{ github.ref }} (${{ github.sha }})" if [[ ${{ inputs.TARGET }} ]]; then - npm run push -- -s $project --message "$build" --target ${{ inputs.TARGET }} ${{ inputs.FLAGS }} + npm run push -- -s ${{ inputs.PROJECT }} --message "${{ inputs.MESSAGE }}" --target ${{ inputs.TARGET }} ${{ inputs.FLAGS }} fi shell: bash diff --git a/.github/workflows/deploy_latest_release.yml b/.github/workflows/deploy_latest_release.yml new file mode 100644 index 0000000000..4628951b4c --- /dev/null +++ b/.github/workflows/deploy_latest_release.yml @@ -0,0 +1,60 @@ +name: SalesforceCommerceCloud/pwa-kit/deploy_latest_release +on: + # For testing - to be removed + push: + branches: + - 'mrt-test-ci-deploy' + # Run this workflow when a new Github release is published + release: + types: [released] + +jobs: + check-latest-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check if latest release + uses: ./.github/actions/check_if_latest_release + with: + token: ${{ secrets.GITHUB_TOKEN }} + + deploy-bug-bounty: + needs: check-latest-release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup node + id: setup_node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "npm" + + - name: Install Monorepo Dependencies + run: |- + # Install node dependencies + node ./scripts/gtime.js monorepo_install npm ci + + - name: Generate Retail App Demo + uses: ./.github/actions/e2e_generate_app + with: + PROJECT_KEY: "retail-react-app-bug-bounty" + + - name: Create MRT credentials file + uses: "./.github/actions/create_mrt" + with: + mobify_user: ${{ secrets.MOBIFY_STG_CLIENT_USER }} + mobify_api_key: ${{ secrets.MOBIFY_STG_CLIENT_API_KEY }} + + - name: Push Bundle to MRT (Bug Bounty) + uses: "./.github/actions/push_to_mrt" + with: + CWD: "../generated-projects/retail-react-app-bug-bounty" + TARGET: testing + PROJECT: pwa-kit + MESSAGE: "tag ${{ github.event.release.tag_name }}" + FLAGS: --cloud-origin https://cloud-testing.mobify-staging.com -c ~/.mobify --wait diff --git a/e2e/config.js b/e2e/config.js index 427f1437a0..14f9be37df 100644 --- a/e2e/config.js +++ b/e2e/config.js @@ -101,9 +101,11 @@ module.exports = { }, ], "retail-app-private-client": [], + "retail-react-app-bug-bounty": [], }, PRESET: { "retail-app-private-client": "retail-react-app-private-slas-client", + "retail-react-app-bug-bounty": "retail-react-app-bug-bounty", }, EXPECTED_GENERATED_ARTIFACTS: { "retail-app-demo": [ diff --git a/e2e/scripts/generate-project.js b/e2e/scripts/generate-project.js index 997ae9e832..8f10792bbb 100644 --- a/e2e/scripts/generate-project.js +++ b/e2e/scripts/generate-project.js @@ -62,7 +62,8 @@ program 'retail-app-demo', 'retail-app-ext', 'retail-app-no-ext', - 'retail-app-private-client' + 'retail-app-private-client', + 'retail-react-app-bug-bounty' ] if (!validKeys.includes(value)) { throw new Error('Invalid project key.') diff --git a/packages/pwa-kit-create-app/scripts/create-mobify-app.js b/packages/pwa-kit-create-app/scripts/create-mobify-app.js index 7742b00c67..8f331ada46 100755 --- a/packages/pwa-kit-create-app/scripts/create-mobify-app.js +++ b/packages/pwa-kit-create-app/scripts/create-mobify-app.js @@ -320,6 +320,31 @@ const PRESETS = [ assets: ['translations'], private: true }, + { + id: 'retail-react-app-bug-bounty', + name: 'Retail React App Bug Bounty Project', + description: '', + templateSource: { + type: TEMPLATE_SOURCE_NPM, + id: '@salesforce/retail-react-app' + }, + questions: [...EXTENSIBILITY_QUESTIONS, ...RETAIL_REACT_APP_QUESTIONS], + answers: { + ['project.extend']: true, + ['project.hybrid']: false, + ['project.name']: 'retail-react-app', + ['project.commerce.instanceUrl']: 'https://zzec-006.dx.commercecloud.salesforce.com', + ['project.commerce.clientId']: 'b56e7ad3-2237-42c9-8f55-41e63ebca420', + ['project.commerce.siteId']: 'RefArch', + ['project.commerce.organizationId']: 'f_ecom_zzec_006', + ['project.commerce.shortCode']: 'staging-001', + ['project.einstein.clientId']: '1ea06c6e-c936-4324-bcf0-fada93f83bb1', + ['project.einstein.siteId']: 'aaij-MobileFirst', + ['project.commerce.isSlasPrivate']: true + }, + assets: ['translations'], + private: true + }, { id: 'retail-react-app-hybrid-test-project', name: 'Retail React App Hybrid Test Private SLAS Project',