From 7bcde6b1e4d9eabcc5b91b554f4a0abcd4a83c42 Mon Sep 17 00:00:00 2001 From: Moha Date: Sat, 15 Apr 2023 20:35:16 +0200 Subject: [PATCH] Add docker build --- .github/workflows/docker.yml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..d33e20a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +name: Docker Image CI + +on: + push: + branches: [master] + tags: ['v*'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build the Docker image + run: docker build -t squid-exporter . + + - name: Tag the Docker image latest + run: docker tag squid-exporter ${{ secrets.DOCKER_USERNAME }}/squid-exporter:latest + + - name: Push the Docker image latest + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/squid-exporter:latest + + - name: Tag the Docker image version + if: startsWith(github.ref, 'refs/tags/v') + run: docker tag squid-exporter ${{ secrets.DOCKER_USERNAME }}/squid-exporter:${{ github.ref_name }} + + - name: Push the Docker image latest + if: startsWith(github.ref, 'refs/tags/v') + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/squid-exporter:${{ github.ref_name }}