-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (39 loc) · 1.35 KB
/
publish.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
42
43
44
45
46
47
name: Publish to GitHub Container Registry
on:
push:
branches:
- master
- main
- publish_container
permissions:
contents: read
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- 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 repository name and organization
- name: Set up repository info
run: |
echo "REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "ORG_NAME=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# Step 4: Build the Docker image
- name: Build Docker Image
run: |
echo "Building image: ghcr.io/${ORG_NAME}/${REPO_NAME}:latest"
docker build -t ghcr.io/${ORG_NAME}/${REPO_NAME}:latest .
# Step 5: Push the Docker image
- name: Push Docker Image
run: |
echo "Pushing image: ghcr.io/${ORG_NAME}/${REPO_NAME}:latest"
docker push ghcr.io/${ORG_NAME}/${REPO_NAME}:latest