1
- name : Build & Deploy
1
+ #
2
+ name : Create and publish a Docker image
2
3
3
4
on :
4
5
push :
5
- branches : [ " main" ]
6
+ branches : [' main' ]
6
7
7
- pull_request :
8
- branches : [ "main" ]
8
+ env :
9
+ REGISTRY : ghcr.io
10
+ IMAGE_NAME : ${{ github.repository }}
9
11
10
12
jobs :
11
- build-and-deploy :
12
- env :
13
- PUBLIC_GRAPHQL_API_URL : " https://api.vra.stevecrow.dev"
13
+ build-and-push-image :
14
14
runs-on : ubuntu-latest
15
-
16
- strategy :
17
- matrix :
18
- node-version : [ 18.x ]
19
-
15
+ permissions :
16
+ contents : read
17
+ packages : write
18
+ attestations : write
19
+ id-token : write
20
20
steps :
21
- - name : Check out repository
21
+ - name : Checkout repository
22
22
uses : actions/checkout@v4
23
-
24
- - name : Use Node.js ${{ matrix.node-version }}
25
- uses : actions/setup-node@v3
23
+ - name : Log in to the Container registry
24
+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
26
25
with :
27
- node-version : ${{ matrix.node-version }}
28
- cache : " npm"
29
-
30
- - run : npm ci
31
- - run : npm run build --if-present
32
- - run : npm run test --if-present
33
-
34
-
26
+ registry : ${{ env.REGISTRY }}
27
+ username : ${{ github.actor }}
28
+ password : ${{ secrets.GITHUB_TOKEN }}
29
+ - name : Extract metadata (tags, labels) for Docker
30
+ id : meta
31
+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
35
32
with :
36
- command : c
37
- cwd : " ./"
38
- files : |
39
- build/
40
- Dockerfile
41
- node_modules/
42
- package.json
43
- package-lock.json
44
- outPath : deploy.tar
45
-
46
- - name : Deploy App to CapRover
47
-
33
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34
+ - name : Build and push Docker image
35
+ id : push
36
+ uses : docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
48
37
with :
49
- server : ' ${{ secrets.CAPROVER_SERVER }}'
50
- app : ' ${{ secrets.CLIENT_APP_NAME }}'
51
- token : ' ${{ secrets.CLIENT_APP_TOKEN }}'
38
+ context : .
39
+ push : true
40
+ tags : ${{ steps.meta.outputs.tags }}
41
+ labels : ${{ steps.meta.outputs.labels }}
42
+ - name : Generate artifact attestation
43
+ uses : actions/attest-build-provenance@v2
44
+ with :
45
+ subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
46
+ subject-digest : ${{ steps.push.outputs.digest }}
47
+ push-to-registry : true
48
+
0 commit comments