-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (36 loc) · 1.31 KB
/
docker-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Build and Deploy to GitHub Packages
on:
push:
branches:
- main # Adjust to your default branch
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Step 3: Set up Docker Buildx for multi-platform builds (optional but recommended)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 4: Build and push the Docker image to GitHub Container Registry
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/osf-site:latest
ghcr.io/${{ github.repository_owner }}/osf-site:${{ github.sha }}
# Step 5: Optional - Clean up unused Docker resources on the runner
- name: Prune Docker
run: docker system prune --all --force