Skip to content

Commit

Permalink
build: Set up Docker auto build with GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
akim-13 committed Sep 20, 2024
1 parent b78ee0f commit cafcc0e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Dockerfile.tsc will still be used.
.env
.git
.github
.gitignore
.vscode
post-checkout
docker-compose*
Dockerfile*
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and deploy Docker image

on:
push:
branches:
# WARNING: Change to production!
- docker

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Log in to GHCR
# WARNING: GHCR Personal Access Token expires! Recreate every 90 days.
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and tag Docker image
run: |
IMAGE_NAME=ghcr.io/${{ github.repository }}:${{ github.sha }}
docker buildx build -t $IMAGE_NAME .
docker tag $IMAGE_NAME ghcr.io/${{ github.repository }}:latest
echo "Image built: $IMAGE_NAME"
- name: Push Docker image to GHCR
run: |
IMAGE_NAME=ghcr.io/${{ github.repository }}:${{ github.sha }}
docker push $IMAGE_NAME
docker push ghcr.io/${{ github.repository }}:latest
echo "Image pushed: $IMAGE_NAME"

0 comments on commit cafcc0e

Please sign in to comment.