Last active
May 6, 2021 16:53
-
-
Save thanakijwanavit/4f674dfb7d6665693947461eac399d40 to your computer and use it in GitHub Desktop.
github action spec for deploy sam project
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: thanakijwanavit/samdocker:262b65b9daa5ae84f9b8b33670f50f69f5e4c8ee | |
steps: | |
- name: Inject slug/short variables | |
uses: rlespinasse/[email protected] | |
- name: install prereq | |
run: | | |
apt update &&\ | |
apt install -y sudo 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=${{ env.GITHUB_REF_SLUG }}" \ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment