diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml new file mode 100644 index 0000000..7fde37a --- /dev/null +++ b/.github/workflows/dockerimage.yml @@ -0,0 +1,17 @@ +name: Docker Image CI + +on: + push: + branches: ["master"] + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 6228a1c..68b3c90 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,4 +1,7 @@ -on: [push, pull_request] +on: + push: + branches: ["master"] + pull_request: name: linting jobs: linting: @@ -7,4 +10,4 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Run golangci-lint - uses: actions-contrib/golangci-lint@v1 \ No newline at end of file + uses: actions-contrib/golangci-lint@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a846837..55c37b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,3 +28,10 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Release docker file + - name: Build the Docker image + run: docker build -t docker.pkg.github.com/hikhvar/mqtt2prometheus/mqtt2prometheus:latest -t docker.pkg.github.com/hikhvar/mqtt2prometheus/mqtt2prometheus:${{ github.ref }} . + - name: Login to Github + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + - name: Publish image + run: docker push docker.pkg.github.com/hikhvar/mqtt2prometheus:latest docker.pkg.github.com/hikhvar/mqtt2prometheus:${{ github.ref }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5eb4a04..351572c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,7 @@ -on: [push, pull_request] +on: + push: + branches: ["master"] + pull_request: name: tests jobs: test: @@ -17,4 +20,4 @@ jobs: - name: Test run: go test ./... - name: Vet - run: go vet ./... \ No newline at end of file + run: go vet ./...