Created
December 3, 2023 01:57
-
-
Save thanakijwanavit/d1baef0fff4a84b6723f724a6234ad75 to your computer and use it in GitHub Desktop.
sam deployment for python3.8 using official image
This file contains hidden or 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
name: deploy | |
on: | |
push: | |
branches: | |
- 'master' | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: install prereq | |
run: | | |
sudo apt update &&\ | |
sudo apt install -y sudo zip bash | |
- name: scan and build all layers | |
run: | | |
bash <(curl -s https://gist.githubusercontent.com/thanakijwanavit/fd8a08c282dcf366a3cbbf086e47b830/raw/buildAllLayers.sh) | |
- name: zip everything | |
run: zip -r everything.zip . | |
- name: persist to workspace | |
uses: actions/upload-artifact@v2 | |
with: | |
name: builtPackages | |
path: ./everything.zip | |
deploy: | |
name: deploy | |
runs-on: ubuntu-latest | |
needs: build | |
container: | |
image: public.ecr.aws/sam/build-python3.8 | |
steps: | |
- name: Inject slug/short variables | |
uses: rlespinasse/[email protected] | |
- name: install prereq | |
run: | | |
yum update -y &&\ | |
yum install -y zip bash | |
- name: downloadPackage from build | |
uses: actions/download-artifact@v2 | |
with: | |
name: builtPackages | |
- name: unzip everything | |
run: | | |
unzip everything.zip | |
- name: Configure AWS credentials from Production account | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-southeast-1 | |
- name: build and deploy sam | |
run: | | |
sam build --debug&&\ | |
sam deploy --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --debug --parameter-overrides \ | |
"BRANCH=master" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment