chore: Update golang.yml workflow to copy golang-build-deploy.sh from… #65
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: 'Golang Lambda Build and Deployment with S3' | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
Golang-lambda-build: | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }} | |
AWS_REGION: ${{ vars.AWS_REGION }} | |
steps: | |
- name: Checkout | |
id: checkout_source_code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
# Checkout the source code from the repository | |
- name: Setup Golang | |
id: setup_golang | |
uses: actions/[email protected] | |
# Set up the Go environment | |
- name: action-zip | |
uses: montudor/[email protected] | |
# Zip the source code | |
- name: Setting up change file detection action | |
id: changed-files-specific | |
uses: tj-actions/changed-files@v44 | |
with: | |
base_sha: ${{ steps.get-base-sha.outputs.base_sha }} | |
files: | | |
**/*.go | |
json: "true" | |
# Detect any changes in the Go files | |
- name: Run step if any file(s) in the integration folder change | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
run: | | |
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}" | |
echo "${{ steps.changed-files-specific.outputs.all_changed_files }}" > list.txt | |
cp .github/scripts/golang-build-deploy.sh . | |
bash golang-build-deploy.sh | |
# Execute build and deploy script if any Go files have changed | |
- name: Setup Terraform | |
id: Setting_up_terraform | |
uses: hashicorp/[email protected] | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
# Set up Terraform CLI | |
- name: Adding workspace configuration in provider.tf | |
id: Adding_workspace_configuration | |
run: | | |
echo "$TF_WORKSPACE" >> main.tf | |
env: | |
TF_WORKSPACE: ${{ vars.TF_WORKSPACE }} | |
# Add workspace configuration to provider.tf file | |
- name: Terraform Init | |
id: Terraform_init | |
run: terraform init | |
# Initialize Terraform | |
- name: Terraform Plan | |
id: Terraform_plan | |
run: terraform plan -input=false -out=golang.tfplan | |
# Generate Terraform plan | |
- name: Terraform Apply | |
id: Terraform_apply | |
run: terraform apply -auto-approve -input=false "golang.tfplan" | |
# Apply Terraform changes |