digital-ocean-volume-snapshots/.github/workflows/docker-build.yml

41 lines
1.1 KiB
YAML
Raw Normal View History

name: Build Docker Image
on:
push:
paths:
- "cmd/**"
branches: [main]
jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout Source code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get short hash of commit
id: sha_short
shell: bash
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
topgg/digitaloceansnapshotter:${{ steps.sha_short.outputs.sha_short }}
topgg/digitaloceansnapshotter:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}