generated from actions-workshop/actions-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 1.78 KB
/
packaging-and-deployment.yml
File metadata and controls
75 lines (66 loc) · 1.78 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
name: Packaging
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Use Node.js 20.x
uses: actions/setup-node@v6
with:
node-version: 20.x
cache: npm
- run: npm ci
env:
CYPRESS_INSTALL_BINARY: 0
- run: npm run build --if-present
- run: npm test
- name: Report Coverage
uses: davelosert/vitest-coverage-report-action@v2
if: always()
package-and-publish:
needs:
- build
name: 🐳 Package & Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref || 'main' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Docker Login
uses: docker/login-action@v4.0.0
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Generate Docker Metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=sha,event=branch,prefix=,format=short
- name: Build and Push Docker Image
uses: docker/build-push-action@v7
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max