Skip to content

Commit

Permalink
build(gh-action): simplify pipeline and prevent push old images
Browse files Browse the repository at this point in the history
  • Loading branch information
clementnuss committed Nov 23, 2022
1 parent 199b3fb commit 408ffa1
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: goreleaser
name: hostlookuper

on:
pull_request:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Login to DockerHub
uses: docker/#-action@v2
with:
username: postfinance
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
Expand All @@ -43,16 +43,18 @@ jobs:
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: |
docker image ls --format "{{.Repository}}:{{.Tag}}" | grep hostlookuper | xargs -I{} docker push '{}'
cat images | xargs -d ' ' -I{} -n1 sh -c "docker push {}"
- name: Create and push manifest for :snapshot tag
run: |
docker image ls --format "{{.Repository}}:{{.Tag}}" | grep hostlookuper | paste -sd ' ' /dev/stdin > images
docker manifest create postfinance/hostlookuper:snapshot $(cat images)
docker manifest push postfinance/hostlookuper:snapshot
docker manifest create $GITHUB_REPOSITORY:snapshot $(cat images)
docker manifest push $GITHUB_REPOSITORY:snapshot
release:
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -70,9 +72,8 @@ jobs:
- name: Login to DockerHub
uses: docker/#-action@v2
with:
username: postfinance
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
Expand Down

0 comments on commit 408ffa1

Please # to comment.