Skip to content

Commit 2d2b717

Browse files
committed
Push container regularly
1 parent 0a3ebc9 commit 2d2b717

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.github/workflows/prod_container_img.yml

+27-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ on:
2222
branches: ["master"]
2323
pull_request:
2424
branches: ["master"]
25+
schedule:
26+
- cron: '0 3 * * *'
27+
28+
env:
29+
IMAGE_NAME: delpa-redirection-server
2530

2631
jobs:
27-
test:
32+
build:
2833
name: Production Container Image
2934
runs-on: ubuntu-24.04
35+
permissions:
36+
packages: write
37+
contents: read
3038

3139
steps:
3240
- uses: actions/[email protected]
@@ -44,10 +52,27 @@ jobs:
4452
run: npm run build_prod
4553

4654
- name: Start the container
47-
run: podman run --detach -p 3000:80 -p 3001:443 delpa-redirection-server
55+
run: podman run --detach -p 3000:80 -p 3001:443 $IMAGE_NAME
4856

4957
- name: Install npm dependencies
5058
run: npm ci
5159

5260
- name: Run test
5361
run: npm run test_prod
62+
63+
# Push Only run below on master
64+
- name: Log in to registry
65+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
66+
67+
- name: Push image
68+
run: |
69+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
70+
71+
# This changes all uppercase characters to lowercase.
72+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
73+
VERSION=latest
74+
75+
echo IMAGE_ID=$IMAGE_ID
76+
echo VERSION=$VERSION
77+
podman tag $IMAGE_NAME $IMAGE_ID:$VERSION
78+
podman push $IMAGE_ID:$VERSION

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ FROM docker.io/caddy:2.8.4-alpine@sha256:e97e0e3f8f51be708a9d5fadbbd75e3398c22fc
5151

5252
LABEL org.opencontainers.image.authors="Hong Xu <[email protected]>"
5353
LABEL org.opencontainers.image.title="Delpa Redirection Server"
54+
LABEL org.opencontainers.image.source=https://github.com/delpa-org/redirection-server
5455
LABEL org.opencontainers.image.licenses=AGPL-3.0-or-later
5556

5657
COPY --from=caddyfile-builder Caddyfile /etc/caddy/

0 commit comments

Comments
 (0)