Added GitHub Actions workflow
This commit is contained in:
parent
574ea58b95
commit
6b4a7e87fd
|
@ -0,0 +1,57 @@
|
||||||
|
name: Publish Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['master']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Push Docker Image to Docker Hub
|
||||||
|
runs-on: Ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Cache Docker Layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }} -buildx-
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
# Add comments to run your tests here
|
||||||
|
echo "Running tests..."
|
||||||
|
# Example: go test ./...
|
||||||
|
go test ./...
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ secrets.DOCKER_USERNAME }}/guestbook-go:latest
|
||||||
|
${{ secrets.DOCKER_USERNAME }}/guestbook-go:${{ github.sha }}
|
||||||
|
cache-from: type=local, src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local, dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Post Build Cleanup
|
||||||
|
run: rm -rf /tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue