env:
  RUBY_VERSION: 2.7.2


name: Build Push
on:
  push:
    branches: "master"

jobs:
  main:
    name: Build Docker Image
    runs-on: ubuntu-18.04
    steps:
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        
      - name: Login to Github Container Registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Compute Short SHA
        uses: benjlevesque/short-sha@v1.2
        id: short-sha
        with:
          length: 7

      - name: Get Branch Name
        uses: tj-actions/branch-names@v2
        id: branch-name

      - name: Build and Push latest
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: |
            bigbluebutton/greenlight:master
            bigbluebutton/greenlight:latest
          build-args: version_code=${{ steps.branch-name.outputs.ref_branch }} (${{ steps.short-sha.outputs.sha }})