-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
849faab
commit f002672
Showing
7 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Build and Deploy Python | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/_test-lambda-python.yaml' | ||
- '.github/workflows/lambda-python.yaml' | ||
- 'lambda/python/**' | ||
|
||
jobs: | ||
test: | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: tests/lambda/python | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
build: | ||
uses: ./.github/workflows/lambda-python.yaml | ||
needs: test | ||
with: | ||
python_version: "1.12" | ||
source_dir: tests/lambda/python | ||
gh_artifact_name: tests-lambda-python | ||
gh_artifact_path: tests/lambda/python/python.zip | ||
gh_artifact_retention_days: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Build Python Lambda | ||
on: | ||
workflow_call: | ||
inputs: | ||
python_version: | ||
description: "Python version" | ||
type: string | ||
default: "3.12" | ||
source_dir: | ||
description: "Directory of the Lambda source code" | ||
type: string | ||
required: true | ||
gh_artifact_name: | ||
description: "Name of the artifact to upload" | ||
type: string | ||
gh_artifact_path: | ||
description: "A file, directory or wildcard pattern that describes what to upload" | ||
type: string | ||
default: "**/*.zip" | ||
gh_artifact_retention_days: | ||
description: "Number of days to retain the artifact" | ||
type: number | ||
default: 30 | ||
jobs: | ||
build: | ||
name: Build Python | ||
runs-on: ubuntu-latest | ||
env: | ||
PYTHON_VERSION: ${{ inputs.python_version }} | ||
SOURCE_DIR: ${{ inputs.source_dir }} | ||
defaults: | ||
run: | ||
working-directory: ${{ env.SOURCE_DIR }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Download Python modules and zip | ||
run: | | ||
pip install -r requirements.txt -t . | ||
zip -r $(basename $PWD).zip . | ||
- name: Archive | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 | ||
with: | ||
name: ${{ inputs.gh_artifact_name }} | ||
path: ${{ inputs.gh_artifact_path }} | ||
if-no-files-found: error | ||
retention-days: ${{ inputs.gh_artifact_retention_days }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,5 @@ site/ | |
# Virtual environment | ||
venv/ | ||
.venv/ | ||
# cache | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: Build Python Lambda | ||
--- | ||
|
||
<!-- action-docs-header source=".github/workflows/lambda-python.yaml" --> | ||
# Build Python Lambda | ||
<!-- action-docs-header source=".github/workflows/lambda-python.yaml" --> | ||
|
||
## Description | ||
|
||
Simple workflow to build a Python Lambda function and upload the artifact to the GitHub artifact store. | ||
|
||
All modules defined in the `packages.txt` file will be installed and packaged into a zip file. | ||
|
||
<!-- action-docs-inputs source=".github/workflows/lambda-python.yaml" --> | ||
## Inputs | ||
|
||
| name | description | type | required | default | | ||
| --- | --- | --- | --- | --- | | ||
| `python_version` | <p>Python version</p> | `string` | `false` | `3.12` | | ||
| `source_dir` | <p>Directory of the Lambda source code</p> | `string` | `true` | `""` | | ||
| `gh_artifact_name` | <p>Name of the artifact to upload</p> | `string` | `false` | `""` | | ||
| `gh_artifact_path` | <p>A file, directory or wildcard pattern that describes what to upload</p> | `string` | `false` | `**/*.zip` | | ||
| `gh_artifact_retention_days` | <p>Number of days to retain the artifact</p> | `number` | `false` | `30` | | ||
<!-- action-docs-inputs source=".github/workflows/lambda-python.yaml" --> | ||
|
||
<!-- action-docs-outputs source=".github/workflows/lambda-python.yaml" --> | ||
|
||
<!-- action-docs-outputs source=".github/workflows/lambda-python.yaml" --> | ||
|
||
<!-- action-docs-usage source=".github/workflows/lambda-python.yaml" project="tx-pts-dai/github-workflows/.github/workflows/lambda-python.yaml" version="v1" --> | ||
## Usage | ||
|
||
```yaml | ||
jobs: | ||
job1: | ||
uses: tx-pts-dai/github-workflows/.github/workflows/lambda-python.yaml@v1 | ||
with: | ||
python_version: | ||
# Python version | ||
# | ||
# Type: string | ||
# Required: false | ||
# Default: 3.12 | ||
|
||
source_dir: | ||
# Directory of the Lambda source code | ||
# | ||
# Type: string | ||
# Required: true | ||
# Default: "" | ||
|
||
gh_artifact_name: | ||
# Name of the artifact to upload | ||
# | ||
# Type: string | ||
# Required: false | ||
# Default: "" | ||
|
||
gh_artifact_path: | ||
# A file, directory or wildcard pattern that describes what to upload | ||
# | ||
# Type: string | ||
# Required: false | ||
# Default: **/lambda.zip | ||
|
||
gh_artifact_retention_days: | ||
# Number of days to retain the artifact | ||
# | ||
# Type: number | ||
# Required: false | ||
# Default: 30 | ||
``` | ||
<!-- action-docs-usage source=".github/workflows/lambda-python.yaml" project="tx-pts-dai/github-workflows/.github/workflows/lambda-python.yaml" version="v1" --> | ||
|
||
# Example | ||
|
||
``` | ||
name: Build | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
build: | ||
uses: tx-pts-dai/github-workflows/.github/workflows/lambda-python.yaml@v1 | ||
with: | ||
python_version: "3.12" | ||
source_dir: lambdas/first_lambda | ||
``` | ||
|
||
# FAQ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import requests | ||
|
||
h = 'https://www.example.com' | ||
r = requests.get(h) | ||
s = r.status_code | ||
print(f"{h} returns {s} status code") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests == 2.32.3 |