diff --git a/.github/actions/generate_test_sitemap_and_robots/action.yml b/.github/actions/generate_test_sitemap_and_robots/action.yml new file mode 100644 index 0000000..17f8a18 --- /dev/null +++ b/.github/actions/generate_test_sitemap_and_robots/action.yml @@ -0,0 +1,23 @@ +name: "Generate Test Sitemap.xml and Robots.txt" +description: "Generate test version of Sitemap.xml and robots.txt for staging domain" +inputs: + main_domain: + description: "Main domain for sitemap replacement" + required: true +runs: + using: "composite" + steps: + - name: Replace sitemap URLs and create directories for test + shell: bash + env: + MAIN_DOMAIN: ${{ inputs.main_domain }} + run: | + mkdir test_content + domain_name=$(echo $MAIN_DOMAIN | sed 's|https://||g') + mkdir -p test_content/$domain_name + cp sitemap.xml test_content/$domain_name/sitemap.xml + cp robots.txt test_content/$domain_name/robots.txt + node .github/modify_sitemap.js --new-domain $domain_name --input-file test_content/$domain_name/sitemap.xml + node .github/modify_robots.js --sitemap-url $domain_name --input-file test_content/$domain_name/robots.txt + cp test_content/$domain_name/sitemap.xml sitemap.xml + cp test_content/$domain_name/robots.txt robots.txt \ No newline at end of file diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml index 7e85591..700ffad 100644 --- a/.github/workflows/publish-website.yml +++ b/.github/workflows/publish-website.yml @@ -123,3 +123,25 @@ jobs: with: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} MESSAGE: ${{ env.MESSAGE }} + + generate_test_sitemap: + runs-on: ubuntu-latest + needs: publish_site + if: ${{ needs.publish_site.result == 'success' }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Generate Test Sitemap and Robots.txt + uses: ./.github/actions/generate_test_sitemap_and_robots + with: + main_domain: "https://staging.deriv.com" + + - name: Save Test Sitemap and Robots as Artifacts + uses: actions/upload-artifact@v3 + with: + name: test-sitemap-robots + path: | + sitemap.xml + robots.txt + retention-days: 5