Improve error handling #48
Workflow file for this run
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
name: Check, build and deploy | |
on: [push, pull_request] | |
jobs: | |
check-code: | |
name: Check code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.16 | |
- name: Lint | |
uses: golangci/golangci-lint-action@v2 | |
with: | |
skip-go-installation: true | |
- name: Tidy | |
run: bash scripts/tidy.sh | |
- name: Test | |
run: bash scripts/test.sh | |
build-and-pack: | |
name: Build and pack | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
env: | |
BINARY_NAME: almendruco | |
outputs: | |
package-name: ${{ steps.pack.outputs.package-name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.16 | |
- name: Build | |
run: bash scripts/build.sh ${BINARY_NAME} | |
- name: Pack | |
id: pack | |
run: | | |
PACKAGE_NAME=${BINARY_NAME}-$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD).zip | |
bash scripts/pack.sh ${BINARY_NAME} ${PACKAGE_NAME} | |
echo "::set-output name=package-name::${PACKAGE_NAME}" | |
- name: Upload package | |
uses: actions/upload-artifact@v2 | |
with: | |
name: package | |
path: ${{ steps.pack.outputs.package-name }} | |
deploy-dry-run: | |
name: Deploy (dry-run) | |
runs-on: ubuntu-latest | |
needs: | |
- build-and-pack | |
permissions: | |
id-token: write | |
env: | |
LAMBDA_NAME: almendruco | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 900 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download package | |
uses: actions/download-artifact@v2 | |
with: | |
name: package | |
- name: Update lambda (dry-run) | |
run: | | |
bash scripts/update.sh \ | |
${LAMBDA_NAME} \ | |
${{ needs.build-and-pack.outputs.package-name }} \ | |
>/dev/null | |
deploy: | |
name: Deploy (production, main only) | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: | |
- check-code | |
- build-and-pack | |
- deploy-dry-run | |
permissions: | |
id-token: write | |
env: | |
LAMBDA_NAME: almendruco | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
role-duration-seconds: 900 | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download package | |
uses: actions/download-artifact@v2 | |
with: | |
name: package | |
- name: Update lambda | |
run: | | |
bash scripts/update.sh -r \ | |
${LAMBDA_NAME} \ | |
${{ needs.build-and-pack.outputs.package-name }} \ | |
>/dev/null |