File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Build and Push Docker Image
2+
3+ on :
4+ push :
5+ tags :
6+ - " *"
7+ workflow_dispatch :
8+
9+ jobs :
10+ build-and-push :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ # Checkout the repository
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+
18+ # Get the short commit hash
19+ - name : Get short commit hash
20+ id : vars
21+ run : echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
22+
23+ # Log in to GitHub Docker Registry
24+ - name : Log in to GitHub Docker Registry
25+ run : echo "$" | docker login ghcr.io -u $ --password-stdin
26+
27+ # Build the Docker image
28+ - name : Build Docker image
29+ run : |
30+ REPO_OWNER=$(echo "$" | tr '[:upper:]' '[:lower:]')
31+ REPO_NAME=$(echo "$" | tr '[:upper:]' '[:lower:]')
32+ IMAGE_TAG=$([[ "$" == "push" && "$" =~ ^refs/tags/ ]] && echo "$" || echo "$")
33+ docker build . --file Dockerfile --tag ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG}
34+ docker tag ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG} ghcr.io/$REPO_OWNER/$REPO_NAME:latest
35+
36+ # Push the Docker image to GitHub Container Registry
37+ - name : Push Docker image
38+ run : |
39+ REPO_OWNER=$(echo "$" | tr '[:upper:]' '[:lower:]')
40+ REPO_NAME=$(echo "$" | tr '[:upper:]' '[:lower:]')
41+ IMAGE_TAG=$([[ "$" == "push" && "$" =~ ^refs/tags/ ]] && echo "$" || echo "$")
42+ docker push ghcr.io/$REPO_OWNER/$REPO_NAME:${IMAGE_TAG}
43+ docker push ghcr.io/$REPO_OWNER/$REPO_NAME:latest
You can’t perform that action at this time.
0 commit comments