# Running goreleaser with the snapshot flag allows us to run some custom validations
# on our build without publishing: https://goreleaser.com/customization/snapshots/

name: test-snapshot

on:
  push:
    paths:
    - '.goreleaser/**'
  pull_request:
    paths:
    - 'goreleaser/**'

jobs:
  build-linux:
    runs-on: ubuntu-latest
    env:
      # https://goreleaser.com/customization/docker_manifest/
      DOCKER_CLI_EXPERIMENTAL: "enabled"

    steps:
      - name: Code checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      -
        name: Docker Login
        env:
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
        run: |
          echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.19
      - name: Run GoReleaser Snapshot
        uses: goreleaser/goreleaser-action@v2
        with:
          version: v0.184.0
          args: release -f .goreleaser/linux.yml --rm-dist --snapshot
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ARTIFACTORY_SECRET: ${{ secrets.ARTIFACTORY_SECRET }}
