-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (32 loc) · 1.05 KB
/
dockerize.yaml
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
name: Build and Push to GHCR
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to GitHub Container Registry
run: echo "${{ secrets.github_token }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: downcase REPO
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Build and tag Docker image
run: |
docker build -t ghcr.io/${REPO}:${{ github.sha }} .
docker tag ghcr.io/${REPO}:${{ github.sha }} ghcr.io/${REPO}:latest
- name: Push Docker image to GHCR
run: |
docker push ghcr.io/${REPO}:${{ github.sha }}
docker push ghcr.io/${REPO}:latest
- name: Cleanup
run: |
docker builder prune -a -f
docker logout ghcr.io