Skip to content

Commit

Permalink
Add docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
boynux committed Apr 15, 2023
1 parent b31e42a commit 7bcde6b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 7bcde6b

Please sign in to comment.