name: Build and push latest image

on:
  push:
    branches:
      - main
      - stable

jobs:
  build:
    if: ${{ github.repository == 'p4lang/PI' && github.event_name == 'push' }}
    runs-on: [ubuntu-latest]
    steps:
    - uses: actions/checkout@v2
    - name: Determine Docker image tag
      id: get-tag
      shell: bash
      run: |
        TAG=""
        if [[ "$GITHUB_REF" =~ "main" ]]; then
            TAG="latest"
        elif [[ "$GITHUB_REF" =~ "stable" ]]; then
            TAG="stable"
        else
            echo "Invalid Github ref $GITHUB_REF"
            exit 1
        fi
        echo "Tag is $TAG"
        echo "::set-output name=tag::$TAG"
    - name: Build and push Docker image to registry
      env:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
      run: |
        echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
        docker build -t p4lang/PI:${{ steps.get-tag.outputs.tag }} .
        docker push p4lang/PI:${{ steps.get-tag.outputs.tag }}

name: Build and push latest image

on:
  push:
    branches:
      - main
      - stable

jobs:
  build:
    if: ${{ github.repository == 'p4lang/PI' && github.event_name == 'push' }}
    runs-on: [ubuntu-latest]
    steps:
    - uses: actions/checkout@v2
    - name: Determine Docker image tag
      id: get-tag
      shell: bash
      run: |
        TAG=""
        if [[ "$GITHUB_REF" =~ "main" ]]; then
            TAG="latest"
        elif [[ "$GITHUB_REF" =~ "stable" ]]; then
            TAG="stable"
        else
            echo "Invalid Github ref $GITHUB_REF"
            exit 1
        fi
        echo "Tag is $TAG"
        echo "::set-output name=tag::$TAG"
    - name: Build and push Docker image to registry
      env:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
      run: |
        echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
        docker build -t p4lang/pi:${{ steps.get-tag.outputs.tag }} .
        docker push p4lang/pi:${{ steps.get-tag.outputs.tag }}

Fix Docker image name typo in Github workflow
Fix Docker image name typo in Github workflow

p4lang/PI -> p4lang/pi
