Skip to content

Commit 0670fe9

Browse files
committed
Add link-index-updater lambda build job
And reuse it in the release workflow
1 parent 05dfe82 commit 0670fe9

File tree

2 files changed

+73
-18
lines changed

2 files changed

+73
-18
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# This workflow is used to build the link index updater lambda function zip
3+
# that can be deployed to AWS Lambda.
4+
name: Build Link Index Updater Lambda
5+
6+
on:
7+
workflow_dispatch:
8+
workflow_call:
9+
inputs:
10+
ref:
11+
required: false
12+
type: string
13+
outputs:
14+
artifact-id:
15+
description: 'Artifact ID of the uploaded artifact. Can be used to download the artifact in other workflows.'
16+
value: ${{ jobs.build.outputs.artifact-id }}
17+
artifact-path:
18+
description: 'Path to the zip file.'
19+
value: ${{ jobs.build.outputs.zip-file }}
20+
21+
jobs:
22+
build:
23+
outputs:
24+
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
25+
zip-file: ${{ steps.create-zip.outputs.zip-file }}
26+
runs-on: ubuntu-latest
27+
env:
28+
ZIP_FILE: link-index-updater-lambda.zip
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ inputs.ref }}
33+
- name: Amazon Linux 2023 build
34+
run: |
35+
docker build . -t publish-links-index:latest -f src/infra/docs-lambda-index-publisher/lambda.DockerFile
36+
- name: Get bootstrap binary
37+
run: |
38+
docker cp $(docker create --name tc publish-links-index:latest):/app/.artifacts/publish ./.artifacts && docker rm tc
39+
- name: Create zip file
40+
id: create-zip
41+
run: |
42+
zip -j "${ZIP_FILE}" .artifacts/docs-lambda-index-publisher/release_linux-x64/bootstrap
43+
echo "zip-file=${ZIP_FILE}" >> "${GITHUB_OUTPUT}"
44+
- name: Archive artifact
45+
id: upload-artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: link-index-updater-lambda
49+
retention-days: 7
50+
if-no-files-found: error
51+
path: ${{ env.ZIP_FILE }}

.github/workflows/release.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
})
4545
4646
containers:
47+
needs:
48+
- release-drafter
4749
runs-on: ubuntu-latest
4850
outputs:
4951
full-version: ${{ steps.bootstrap.outputs.full-version }}
@@ -52,7 +54,7 @@ jobs:
5254
steps:
5355
- uses: actions/checkout@v4
5456
with:
55-
ref: ${{ steps.release-drafter.outputs.tag_name }}
57+
ref: ${{ needs.release-drafter.outputs.tag_name }}
5658
- name: Bootstrap Action Workspace
5759
id: bootstrap
5860
uses: ./.github/actions/bootstrap
@@ -65,46 +67,48 @@ jobs:
6567
password: ${{ secrets.GITHUB_TOKEN }}
6668

6769
- name: Publish Containers
68-
run: ./build.sh publishcontainers
70+
run: ./build.sh publishcontainers\
71+
72+
build-lambda:
73+
needs:
74+
- release-drafter
75+
uses: ./.github/workflows/build-link-index-updater-lambda.yml
76+
with:
77+
ref: ${{ needs.release-drafter.outputs.tag_name }}
6978

7079
release-lambda:
7180
environment:
7281
name: link-index-updater-prod
7382
runs-on: ubuntu-latest
7483
needs:
84+
- build-lambda
7585
- release-drafter
7686
permissions:
7787
contents: write
7888
id-token: write
7989
env:
80-
ZIP_FILE: link-index-updater-lambda.zip
90+
ZIP_FILE: ${{ needs.build-lambda.outputs.artifact-path }}
8191
steps:
82-
- uses: actions/checkout@v4
83-
with:
84-
ref: ${{ steps.release-drafter.outputs.tag_name }}
85-
- name: Amazon Linux 2023 build
86-
run: |
87-
docker build . -t publish-links-index:latest -f src/infra/docs-lambda-index-publisher/lambda.DockerFile
88-
- name: Get bootstrap binary
89-
run: |
90-
docker cp $(docker create --name tc publish-links-index:latest):/app/.artifacts/publish ./.artifacts && docker rm tc
91-
92+
93+
- uses: actions/download-artifact@v4
94+
with:
95+
artifact-ids: ${{ needs.build-lambda.outputs.artifact-id }}
96+
9297
- uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
9398
with:
9499
role-to-assume: arn:aws:iam::197730964718:role/elastic-docs-v3-link-index-updater-deployer
95100
aws-region: us-east-2
96-
101+
97102
- name: Upload Lambda function
98-
run: |
99-
zip -j "${ZIP_FILE}" .artifacts/docs-lambda-index-publisher/release_linux-x64/bootstrap
103+
run: |
100104
aws lambda update-function-code \
101105
--function-name elastic-docs-v3-link-index-updater \
102106
--zip-file "fileb://${ZIP_FILE}"
103107
104108
- name: Attach Distribution to release
105109
env:
106110
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
run: gh release upload ${{ needs.release-drafter.outputs.tag_name }} "${ZIP_FILE}"
111+
run: gh release upload --repo ${{ github.repository }} ${{ needs.release-drafter.outputs.tag_name }} "${ZIP_FILE}"
108112

109113
release:
110114
needs:
@@ -126,7 +130,7 @@ jobs:
126130
steps:
127131
- uses: actions/checkout@v4
128132
with:
129-
ref: ${{ steps.release-drafter.outputs.tag_name }}
133+
ref: ${{ needs.release-drafter.outputs.tag_name }}
130134

131135
- name: Bootstrap Action Workspace
132136
id: bootstrap

0 commit comments

Comments
 (0)