-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (85 loc) · 2.85 KB
/
Copy pathdocker-image.yml
File metadata and controls
103 lines (85 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Build and Push Docker Images
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: |
rm -f .npmrc
npm install --include=dev --legacy-peer-deps
test -x node_modules/.bin/next
- name: Build Next standalone output
env:
NEXT_TELEMETRY_DISABLED: '1'
run: npm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Resolve Docker Hub credentials
id: dockerhub
shell: bash
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
username="${DOCKERHUB_USERNAME:-${DOCKERHUB_USER:-duanxiaosheng}}"
password="${DOCKERHUB_TOKEN:-${DOCKER_HUB_TOKEN:-${DOCKERHUB_PASSWORD:-${DOCKER_PASSWORD:-}}}}"
echo "username=$username" >> "$GITHUB_OUTPUT"
if [ -z "$password" ]; then
echo "::error::Missing Docker Hub password/token secret. Set one of: DOCKERHUB_TOKEN, DOCKER_HUB_TOKEN, DOCKERHUB_PASSWORD, DOCKER_PASSWORD"
exit 1
fi
echo "password=$password" >> "$GITHUB_OUTPUT"
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ steps.dockerhub.outputs.username }}
password: ${{ steps.dockerhub.outputs.password }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/duanxiaosheng/2025-blog-public-docker
duanxiaosheng/2025-blog-local-docker
tags: |
type=raw,value=latest
type=sha
type=ref,event=branch
- name: Build and push runtime image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.release
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}