Skip to content

Commit ff0de18

Browse files
authored
Push container regularly (#19)
1 parent 0a3ebc9 commit ff0de18

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

.github/workflows/prod_container_img.yml

+29-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,29 @@ 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+
if: github.ref == 'refs/heads/master'
66+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
67+
68+
- name: Push image
69+
if: github.ref == 'refs/heads/master'
70+
run: |
71+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
72+
73+
# This changes all uppercase characters to lowercase.
74+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
75+
VERSION=latest
76+
77+
echo IMAGE_ID=$IMAGE_ID
78+
echo VERSION=$VERSION
79+
podman tag $IMAGE_NAME $IMAGE_ID:$VERSION
80+
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)