Skip to content

Commit

Permalink
Add build and push step to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastiaanZ committed Nov 14, 2020
1 parent 5081057 commit 0aab283
Showing 1 changed file with 36 additions and 0 deletions.
Expand Up @@ -115,3 +115,39 @@ jobs:
- name: Tear down docker-compose containers
run: docker-compose stop
if: ${{ always() }}

build-and-push:
needs: lint-test
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest

steps:
# Create a commit SHA-based tag for the container repositories
- name: Create SHA Container Tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/python-discord/site:latest
tags: |
ghcr.io/python-discord/site:latest
ghcr.io/python-discord/site:${{ steps.sha_tag.outputs.tag }}

0 comments on commit 0aab283

Please sign in to comment.