Skip to content

Publish website and Upload sitemap and robots #361

Publish website and Upload sitemap and robots

Publish website and Upload sitemap and robots #361

name: Publish website and Upload sitemap and robots
on:
workflow_dispatch:
inputs:
staging_release:
type: boolean
description: "Staging"
default: false
production_release:
type: boolean
description: "Production"
default: false
jobs:
publish_site:
runs-on: ubuntu-latest
outputs:
SITES_ARRAY: ${{ steps.publish.outputs.SITES_ARRAY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install -y jq
- name: Publish Website
id: publish
uses: ./.github/actions/publish_website
with:
staging_release: ${{ github.event.inputs.staging_release }}
production_release: ${{ github.event.inputs.production_release }}
webflow_api_token: ${{ secrets.WEBFLOW_API_TOKEN }}
staging_site_id: ${{ secrets.STAGING_SITE_ID }}
deriv_com_site_id: ${{ secrets.DERIV_COM_SITE_ID }}
deriv_me_site_id: ${{ secrets.DERIV_ME_SITE_ID }}
deriv_be_site_id: ${{ secrets.DERIV_BE_SITE_ID }}
webflow_general_site_id: ${{ secrets.WEBFLOW_GENERAL_SITE_ID }}
send_slack_success:
runs-on: ubuntu-latest
needs: [publish_site]
steps:
- name: Determine Slack Message for Publish Site
id: slack_message_publish
run: |
DATE=$(date '+%Y-%m-%d %H:%M:%S')
SITES_ARRAY=${{ needs.publish_site.outputs.SITES_ARRAY }}
echo "Determined SITES_ARRAY: $SITES_ARRAY"
if [ "${{ needs.publish_site.result }}" == "success" ]; then
echo "MESSAGE=Release succeeded for $SITES_ARRAY at $DATE" >> $GITHUB_ENV
else
echo "MESSAGE=Release failed for $SITES_ARRAY at $DATE" >> $GITHUB_ENV
fi
- name: Send Slack Notification for Publish Site
uses: "deriv-com/shared-actions/.github/actions/send_slack_notification@master"
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: ${{ env.MESSAGE }}
generate_sitemap_and_robots:
runs-on: ubuntu-latest
needs: publish_site
if: ${{ needs.publish_site.result == 'success' && github.event.inputs.production_release == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
- name: Install yargs
shell: bash
run: npm install yargs
- name: Download sitemap.xml and robots.txt
shell: bash
env:
BASE_DOMAIN: "https://staging.deriv.com"
run: |
curl -O $BASE_DOMAIN/sitemap.xml -O $BASE_DOMAIN/robots.txt
- name: Generate Sitemap and Robots.txt
uses: ./.github/actions/generate_sitemap_and_robots
with:
main_domain: "https://deriv.com"
- name: Upload to R2
uses: ./.github/actions/upload_to_r2
with:
r2_account_id: ${{ secrets.R2_ACCOUNT_ID }}
r2_access_key_id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2_secret_access_key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2_bucket_name: ${{ secrets.R2_BUCKET_NAME }}
send_slack_failure:
runs-on: ubuntu-latest
needs: [generate_sitemap_and_robots]
if: failure()
steps:
- name: Determine Slack Message for Sitemap Failure
id: slack_message_sitemap
run: |
DATE=$(date '+%Y-%m-%d %H:%M:%S')
echo "MESSAGE=Sitemap and robots.txt generation failed for latest webflow release at $DATE" >> $GITHUB_ENV
- name: Send Slack Notification for Sitemap Failure
uses: "deriv-com/shared-actions/.github/actions/send_slack_notification@master"
with:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
MESSAGE: ${{ env.MESSAGE }}