-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Set up Docker auto build with GH Actions
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||