hostlookuper #123
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: hostlookuper | |
on: | |
pull_request: | |
push: | |
jobs: | |
check-dockerhub-token: | |
runs-on: ubuntu-latest | |
outputs: | |
HAS_DOCKERHUB_TOKEN: ${{ steps.dockerhub-token.outputs.HAS_DOCKERHUB_TOKEN }} | |
steps: | |
- id: dockerhub-token | |
env: | |
HAS_DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN != '' }} | |
run: | | |
echo "HAS_DOCKERHUB_TOKEN=$HAS_DOCKERHUB_TOKEN" >> $GITHUB_OUTPUT | |
echo "HAS_DOCKERHUB_TOKEN=$HAS_DOCKERHUB_TOKEN" >> $GITHUB_STEP_SUMMARY | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.19 | |
- name: Install golangci-lint | |
uses: golangci/golangci-lint-action@master | |
with: | |
version: v1.50.1 | |
build: | |
needs: | |
- lint | |
- check-dockerhub-token | |
if: | | |
!startsWith(github.ref, 'refs/tags/v') && | |
needs.check-dockerhub-token.outputs.HAS_DOCKERHUB_TOKEN == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.19 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --rm-dist --snapshot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: List snapshot images | |
run: | | |
docker image ls --format "{{.Repository}}:{{.Tag}}" | \ | |
grep -e "$GITHUB_REPOSITORY:.*$(git rev-parse --short HEAD).*" | \ | |
paste -sd ' ' /dev/stdin > images | |
- name: Push snapshot images | |
run: | | |
cat images | xargs -d ' ' -I{} -n1 sh -c "docker push {}" | |
- name: Create and push manifest for :snapshot tag | |
run: | | |
docker manifest create $GITHUB_REPOSITORY:snapshot $(cat images) | |
docker manifest push $GITHUB_REPOSITORY:snapshot | |
release: | |
needs: | |
- lint | |
- check-dockerhub-token | |
if: | | |
startsWith(github.ref, 'refs/tags/v') && | |
needs.check-dockerhub-token.outputs.HAS_DOCKERHUB_TOKEN == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.19 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |