-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (130 loc) · 4.68 KB
/
build.yml
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
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
- issue/*
# - dev/harai
env:
AWS_ACCOUNT_ID: '013230744746'
RELEASE_ACCESS_KEY_ID: AKIAQGFE5ESVJ7IYEUVR
REPO_BUCKET: gutenberg-ext-imglambda-repobucket-1i58nyytyztdl
TEST_ACCESS_KEY_ID: AKIAQGFE5ESVKGVB3XGS
TEST_GENERATED_BUCKET: gutenberg-ext-imglambda-testgeneratedbucket-n8c79jl0mzd2
TEST_ORIGINAL_BUCKET: gutenberg-ext-imglambda-testoriginalbucket-fz28m8cblu5t
PYTHON_VERSION: 3.11.10
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@main
- uses: actions/setup-python@main
with:
python-version: '~${{env.PYTHON_VERSION}}'
- name: Python Poetry Action
uses: abatilo/actions-poetry@master
- run: script/recreate-venv
- name: Generate build number
uses: onyxmueller/build-tag-number@main
with:
token: ${{secrets.GITHUB_TOKEN}}
prefix: build_number_generator
- name: Print new build number
run: echo "Build number is $BUILD_NUMBER"
- name: Save the build number
run: echo "$BUILD_NUMBER" > work/BUILD_NUMBER
- name: Embed build number into code
run: echo "build-$BUILD_NUMBER" > src/origin-request/VERSION
- name: Embed build number into code
run: echo "build-$BUILD_NUMBER" > src/origin-response/VERSION
- run: script/create-lambda
- uses: actions/upload-artifact@main
with:
name: artifact
path: |
work/origin-request.zip
work/origin-response.zip
if-no-files-found: error
- uses: actions/upload-artifact@main
with:
name: build-number
path: work/BUILD_NUMBER
if-no-files-found: error
test:
runs-on: ubuntu-24.04
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@main
- uses: actions/setup-python@main
with:
python-version: '~${{env.PYTHON_VERSION}}'
- name: Python Poetry Action
uses: abatilo/actions-poetry@master
- run: echo "$TEST_ACCESS_KEY_ID" > config/test/access-key-id
- run: echo "$AWS_ACCOUNT_ID" > config/test/aws-account-id
- run: echo "$TEST_GENERATED_BUCKET" > config/test/generated-bucket
- run: echo "$TEST_ORIGINAL_BUCKET" > config/test/original-bucket
- run: echo "$TEST_SECRET_ACCESS_KEY" > config/test/secret-access-key
env:
TEST_SECRET_ACCESS_KEY: ${{secrets.TEST_AWS_SECRET_ACCESS_KEY}}
- run: poetry install --sync
working-directory: src/origin-request
- run: poetry run python -m xmlrunner --output-file ../../work/report-origin-request.xml originrequest/test_index.py 2>&1
working-directory: src/origin-request
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@master
if: always()
with:
files: work/report-origin-request.xml
release:
needs:
- build
- test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@main
with:
name: artifact
- uses: actions/download-artifact@main
with:
name: build-number
- name: set BUILD_NUMBER
run: echo "BUILD_NUMBER=$(< ./BUILD_NUMBER)" >> $GITHUB_ENV
- id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: build-${{env.BUILD_NUMBER}}
release_name: Build ${{env.BUILD_NUMBER}}
draft: false
prerelease: false
- uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ./origin-request.zip
asset_name: origin-request.build-${{env.BUILD_NUMBER}}-awslambda-python3.11.zip
asset_content_type: application/octet-stream
- uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ./origin-response.zip
asset_name: origin-response.build-${{env.BUILD_NUMBER}}-awslambda-python3.11.zip
asset_content_type: application/octet-stream
- uses: aws-actions/configure-aws-credentials@main
with:
aws-access-key-id: ${{env.RELEASE_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.RELEASE_AWS_SECRET_ACCESS_KEY}}
aws-region: us-east-1
- run: aws s3 cp ./origin-request.zip s3://${{env.REPO_BUCKET}}/origin-request.build-${{env.BUILD_NUMBER}}-awslambda-python3.11.zip
- run: aws s3 cp ./origin-response.zip s3://${{env.REPO_BUCKET}}/origin-response.build-${{env.BUILD_NUMBER}}-awslambda-python3.11.zip