Build and push magento2 code to remote server (zero-downtime)

Build and push magento2 code to remote server using magento-actions as follows:

name: m2-actions-test

on: [push]

jobs:
  magento2-build:
    runs-on: ubuntu-latest
    container: ubuntu
    name: 'm2 tests & build'
    services:
      mysql:
        image: docker://mysql:8.0
        env:
          MYSQL_ROOT_PASSWORD: magento
          MYSQL_DATABASE: magento
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      elasticsearch:
        image: docker://elasticsearch:7.1.0
        ports:
          - 9200:9200
        options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
    steps:
    - uses: actions/checkout@v1
      with:
        submodules: recursive
    - name: 'launch magento2 build'
      uses: MAD-I-T/magento-actions@v3.10
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
      with:
        process: 'build'
        elasticsearch: 1
    - name: 'launch magento2 zero downtime deploy'
      if: success()
      uses: MAD-I-T/magento-actions@v3.10
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
        BUCKET_COMMIT: bucket-commit-${{github.sha}}.tar.gz
        MYSQL_ROOT_PASSWORD: magento
        MYSQL_DATABASE: magento
        HOST_DEPLOY_PATH: ${{secrets.STAGE_HOST_DEPLOY_PATH}}
        HOST_DEPLOY_PATH_BUCKET: ${{secrets.STAGE_HOST_DEPLOY_PATH}}/bucket
        SSH_PRIVATE_KEY: ${{secrets.STAGE_SSH_PRIVATE_KEY}}
        SSH_CONFIG: ${{secrets.STAGE_SSH_CONFIG}}
        WRITE_USE_SUDO: false
      with:
        php: '7.4'
        process: 'deploy-staging'
    - name: 'unlock deployer if fails'
      if: failure() || cancelled()
      uses: MAD-I-T/magento-actions@v3.10
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
        BUCKET_COMMIT: bucket-commit-${{github.sha}}.tar.gz
        MYSQL_ROOT_PASSWORD: magento
        MYSQL_DATABASE: magento
        HOST_DEPLOY_PATH: ${{secrets.STAGE_HOST_DEPLOY_PATH}}
        HOST_DEPLOY_PATH_BUCKET: ${{secrets.STAGE_HOST_DEPLOY_PATH}}/bucket
        SSH_PRIVATE_KEY: ${{secrets.STAGE_SSH_PRIVATE_KEY}}
        SSH_CONFIG: ${{secrets.STAGE_SSH_CONFIG}}
        WRITE_USE_SUDO: false
      with:
        php: '7.4'
        process: 'cleanup-staging'

If you encounter permission issues consider disabling permission check as follows (sample)

Full install in video: