galley 0.1.1

A deployment queue for Docker and Nginx.
name: Actions
on:
  push:
    branches:
      - main
  pull_request: {}
jobs:
  style:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          components: rustfmt

      - name: Run check
        run: cargo fmt -- --check

  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          components: clippy

      - name: Run check
        run: cargo clippy --all-targets

  test:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      - name: Run check
        run: cargo test

  is-publishable:
    runs-on: ubuntu-latest
    if: ${{
      github.ref == 'refs/heads/main' &&
      github.event_name == 'push'
      }}
    outputs:
      IS_PUBLISHABLE: ${{ steps.is-publishable.outputs.IS_PUBLISHABLE }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Fetch tags
        run: git fetch --depth=1 --tags origin

      - name: Check if this commit is a release commit
        id: is-publishable
        # Check if this commit has a tag pointing to it with the same message (name) as the commit.
        run: |
          tag=$(git describe --all --exact-match)
          if [[ ${tag#"tags/"} = $(git log -n 1 --pretty=format:%s) ]]
          then
            echo "::set-output name=IS_PUBLISHABLE::true"
          else
            echo "::set-output name=IS_PUBLISHABLE::false"
          fi

  publish:
    runs-on: ubuntu-latest
    needs: [style, lint, test, is-publishable]
    if: ${{
      github.ref == 'refs/heads/main' &&
      github.event_name == 'push' &&
      needs.is-publishable.outputs.IS_PUBLISHABLE == 'true'
      }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      - name: Publish crate
        run: cargo publish --token ${{secrets.CRATES_IO_TOKEN}}