Repository navigation
137 lines (123 loc) · 5.36 KB
/
Copy pathdeploy.yml
File metadata and controls
137 lines (123 loc) · 5.36 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Publish Docker Image to GitHub Container Registry
on:
push:
branches: [ master ]
workflow_dispatch:
permissions:
contents: read
packages: write
id-token: write # For OIDC attestations
attestations: write # For attestations
jobs:
deploy:
name: Publish Docker Image to GitHub Container Registry
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v4
# No longer need Node.js/Ruby setup - builds are handled in Docker multi-stage
- name: Validate Docker build environment
run: |
echo "Docker build environment ready - using optimized 3-builder architecture"
echo "✅ React Portfolio Builder: Node.js 22 Alpine"
echo "✅ Storybook Component Library Builder: Node.js 22 Alpine"
echo "✅ Jekyll Documentation Builder: Ruby 3.2 Alpine"
echo "✅ Production Runtime: Minimal Node.js 22 Alpine"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,format=short
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=Derek Mackley Developer Portfolio
org.opencontainers.image.description=Multi-builder optimized portfolio with React, Storybook, Jekyll docs
org.opencontainers.image.vendor=Derek Mackley
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.url=https://github.com/${{ github.repository }}
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
maintainer=${{ github.actor }}
build.architecture=multi-stage-parallel
build.builders=react,storybook,jekyll
deployment.type=nodejs-express
deployment.framework=vite-react
deployment.environment=production
security.non-root=true
security.user=nextjs:nodejs
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Focus on AMD64 for reliability - ARM64 can be added later if needed
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
# Network timeout configuration for better reliability
build-args: |
NODE_ENV=production
YARN_NETWORK_TIMEOUT=300000
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
echo "Digest: $digest"
- name: Generate image metadata
run: |
echo "### Developer Portfolio Image Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Registry:** ghcr.io" >> $GITHUB_STEP_SUMMARY
echo "**Image:** ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
echo "**Digest:** ${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pull command:**" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "docker pull ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Verify image push
run: |
echo "Verifying image was pushed successfully..."
docker manifest inspect ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
echo "✅ Image verified successfully"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
- name: Deployment complete
run: |
echo "🚀 Deployment completed successfully"
echo "Image: ghcr.io/${{ github.repository }}:latest"
echo "Digest: ${{ steps.build.outputs.digest }}"
echo "All metadata, labels, and attestations applied"