Skip to content

Commit

Permalink
CI to push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmoris committed Dec 9, 2020
1 parent cec1142 commit a895140
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,40 @@ jobs:
- name: Restore
run: dotnet restore src/Giraffe.Website/Giraffe.Website.fsproj
- name: Build
run: dotnet build --configuration Release --no-restore src/Giraffe.Website/Giraffe.Website.fsproj
run: dotnet build --configuration Release --no-restore src/Giraffe.Website/Giraffe.Website.fsproj

deploy:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
env:
PROJECT: giraffefsharp
IMAGE: giraffe-website

steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v2

# Build the Docker image
- name: Build
run: |
PATTERN="refs/tags/v"
SUB=""
TAG="${GITHUB_REF/$PATTERN/$SUB}"
docker build -t "$PROJECT"/"$IMAGE":"$TAG" -f src/Giraffe.Website/Dockerfile .
# Auth with Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

# Push the Docker image to Docker Hub
- name: Publish
run: |
PATTERN="refs/tags/v"
SUB=""
TAG="${GITHUB_REF/$PATTERN/$SUB}"
docker push $PROJECT/$IMAGE:$TAG

0 comments on commit a895140

Please sign in to comment.