Skip to content

Commit 10e0a8a

Browse files
feat: add GitHub Actions workflow for building and pushing Docker images to GitHub Container Registry
1 parent 3ce05ac commit 10e0a8a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Push Docker Image
2+
3+
env:
4+
DOCKER_BUILDKIT: 1
5+
COMPOSE_DOCKER_CLI_BUILD: 1
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
concurrency:
13+
group: ${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
id-token: write
21+
contents: read
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v5
26+
27+
- uses: docker/login-action@v3
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.CR_TOKEN }}
32+
33+
- name: Set Docker image tag
34+
id: set-tag
35+
run: |
36+
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
37+
38+
- name: Build and Push Docker image
39+
working-directory: "./"
40+
run: |
41+
docker build -t ghcr.io/${{ github.repository }}:${{ steps.set-tag.outputs.IMAGE_TAG }} .
42+
docker push ghcr.io/${{ github.repository }}:${{ steps.set-tag.outputs.IMAGE_TAG }}

0 commit comments

Comments
 (0)