name: NATS Server Nightly
on:
  workflow_dispatch: {}

  schedule:
    - cron: "40 4 * * *"


jobs:
  nightly_release:
    runs-on: ubuntu-latest

    env:
      GOPATH: /home/runner/work/nats-server
      GO111MODULE: "off"

    steps:
      - name: Checkout code
        uses: actions/checkout@v1
        with:
          path: src/github.com/nats-io/nats-server

      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.16

      - name: goreleaser
        uses: goreleaser/goreleaser-action@v2
        with:
          version: latest
          args: release --snapshot --config .goreleaser-nightly.yml

      - name: images
        run: |
          docker images

      - name: docker_login
        run: |
          docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}"

      - name: docker_push
        run: |
          NDATE=$(date +%Y%m%d)
          docker push synadia/nats-server:nightly-${NDATE}
          docker push synadia/nats-server:nightly
