Avoid duplication in github workflow

Hi, my current workflow looks something like this, is it possible to avoid having practically the same code twice?

environment staging is set to staging branch and environment production is set to master branch. and the secrets for each environment are different.

on:

  push:

    branches:

      - staging

      - master

jobs:

  push_staging:

    runs-on: ubuntu-latest

    environment: staging

    steps:

      - uses: actions/checkout@v2

      - name: "Install the Realm CLI"

        run: |

          npm install -g mongodb-realm-cli

      - name: Login

        run: |

          realm-cli login --api-key="${{ secrets.REALM_API_PUBLIC_KEY }}" --private-api-key="${{ secrets.REALM_API_PRIVATE_KEY }}" --realm-url https://realm.mongodb.com --atlas-url https://cloud.mongodb.com

      - name: Push

        run: |

          cd site/realm

          realm-cli push --remote="${{ secrets.GATSBY_REALM_APP_ID }}" -y

  push_production:

    runs-on: ubuntu-latest

    environment: production

    steps:

      - uses: actions/checkout@v2

      - name: "Install the Realm CLI"

        run: |

          npm install -g mongodb-realm-cli

      - name: Login

        run: |

          realm-cli login --api-key="${{ secrets.REALM_API_PUBLIC_KEY }}" --private-api-key="${{ secrets.REALM_API_PRIVATE_KEY }}" --realm-url https://realm.mongodb.com --atlas-url https://cloud.mongodb.com

      - name: Push

        run: |

          cd site/realm

          realm-cli push --remote="${{ secrets.GATSBY_REALM_APP_ID }}" -y

thanks