Skip to content

Commit 261f09c

Browse files
committed
Add action
1 parent c4afb19 commit 261f09c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
IMAGE_NAME: shiny-meets-fastapi
11+
VERSION: latest
12+
CONTEXT: routes_example_app
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Build the Docker image
21+
run: |
22+
cd $CONTEXT
23+
docker build . --file Dockerfile --tag $IMAGE_NAME:$VERSION
24+
25+
- name: Log in to registry
26+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u token --password-stdin
27+
28+
- name: Push image to ghcr.io
29+
run: |
30+
image_id=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
31+
# repository name must be lowercase
32+
image_id=$(echo $image_id | tr '[A-Z]' '[a-z]')
33+
docker tag $IMAGE_NAME:$VERSION $image_id:$VERSION
34+
docker push $image_id:$VERSION

0 commit comments

Comments
 (0)