4
4
push :
5
5
tags :
6
6
- v*.*.*
7
+ branches :
8
+ - main
7
9
8
10
permissions :
11
+ attestations : write
9
12
contents : write
13
+ id-token : write
10
14
pull-requests : read
11
15
12
16
jobs :
13
17
release :
14
18
runs-on : ubuntu-latest
19
+ env :
20
+ DOCKER_IMAGE_NAME : docker.elastic.co/observability/apm-agent-nodejs
15
21
steps :
16
22
- uses : actions/checkout@v4
17
23
with :
33
39
34
40
- run : make -C .ci dist
35
41
36
- - run : make -C .ci push-docker
42
+ - name : Attest Lambda layer zip
43
+ uses : github-early-access/generate-build-provenance@main
44
+ with :
45
+ subject-path : " ${{ github.workspace }}/build/aws/elastic-apm-node-lambda-layer-*.zip"
46
+
47
+ - name : Extract metadata (tags, labels)
48
+ id : docker-meta
49
+ uses : docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
50
+ with :
51
+ images : ${{ env.DOCKER_IMAGE_NAME }}
52
+ flavor : |
53
+ latest=auto
54
+ tags : |
55
+ # "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3"
56
+ type=semver,pattern={{version}}
57
+ # "edge" Docker tag on git push to default branch
58
+ type=edge
59
+
60
+ - name : Build and Push Docker Image
61
+ id : docker-push
62
+ uses : docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
63
+ with :
64
+ context : .
65
+ push : true
66
+ tags : ${{ steps.docker-meta.outputs.tags }}
67
+ labels : ${{ steps.docker-meta.outputs.labels }}
68
+ build-args : |
69
+ AGENT_DIR=/build/dist/nodejs
70
+
71
+ - name : Attest Docker image
72
+ uses : github-early-access/generate-build-provenance@main
73
+ with :
74
+ subject-name : " ${{ env.DOCKER_IMAGE_NAME }}"
75
+ subject-digest : ${{ steps.docker-push.outputs.digest }}
76
+ push-to-registry : true
37
77
38
78
- name : Read AWS vault secrets
39
79
@@ -46,12 +86,15 @@ jobs:
46
86
secret/observability-team/ci/service-account/apm-aws-lambda access_key_id | AWS_ACCESS_KEY_ID ;
47
87
secret/observability-team/ci/service-account/apm-aws-lambda secret_access_key | AWS_SECRET_ACCESS_KEY
48
88
49
- - name : Publish AWS lambda
89
+ - name : Publish AWS lambda (only for tag release)
90
+ if : startsWith(github.ref, 'refs/tags')
50
91
run : make -C .ci publish-in-all-aws-regions create-arn-file
51
92
env :
52
93
GH_TOKEN : ${{ github.token }}
53
94
54
- - run : make -C .ci github-release
95
+ - name : create github release (only for tag release)
96
+ run : make -C .ci github-release
97
+ if : startsWith(github.ref, 'refs/tags')
55
98
env :
56
99
GH_TOKEN : ${{ github.token }}
57
100
@@ -66,12 +109,13 @@ jobs:
66
109
secret/jenkins-ci/npmjs/elasticmachine token | NPMJS_TOKEN ;
67
110
totp/code/npmjs-elasticmachine code | TOTP_CODE
68
111
69
- - name : npm publish
112
+ - name : npm publish (only for tag release)
113
+ if : startsWith(github.ref, 'refs/tags')
70
114
run : |-
71
115
echo "//registry.npmjs.org/:_authToken=${{ env.NPMJS_TOKEN }}" > .npmrc
72
- npm publish --otp=${{ env.TOTP_CODE }}
116
+ npm publish --otp=${{ env.TOTP_CODE }} --provenance
73
117
74
- - if : always()
118
+ - if : ${{ always() && startsWith(github.ref, 'refs/tags') }}
75
119
uses : elastic/apm-pipeline-library/.github/actions/notify-build-status@current
76
120
with :
77
121
vaultUrl : ${{ secrets.VAULT_ADDR }}
0 commit comments