Skip to content

Commit

Permalink
set working-directory to infra for all steps
Browse files Browse the repository at this point in the history
  • Loading branch information
artemious7 committed Oct 22, 2024
1 parent 37d1581 commit 25444cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/provision-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ env:
FUNC_PROJECT: TimeTrackerBot/TimeTrackerBot.csproj

jobs:
provision-infrastructure:
name: 'Terraform provisioning'
provision:
name: Terraform provision
runs-on: ubuntu-latest
defaults:
run:
working-directory: infra
env:
#this is needed since we are running terraform with read-only permissions
ARM_SKIP_PROVIDER_REGISTRATION: true
Expand Down Expand Up @@ -55,20 +58,20 @@ jobs:

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform -chdir=infra init -input=false
run: terraform init -input=false

# Checks that all Terraform configuration files adhere to a canonical format
# Will fail the build if not
- name: Terraform Format
run: terraform -chdir=infra fmt -check -recursive
run: terraform fmt -check -recursive

# Generates an execution plan for Terraform
# An exit code of 0 indicated no changes, 1 a terraform failure, 2 there are pending changes.
- name: Terraform Plan
id: tf-plan
run: |
export exitcode=0
terraform -chdir=infra plan -input=false -var="TelegramBotApiKey={{ secrets.TELEGRAM_BOT_API_KEY }}" -var="resource_group=${{ vars.RESOURCE_GROUP }}" -detailed-exitcode -no-color -out tfplan || export exitcode=$?
terraform plan -input=false -var="TelegramBotApiKey={{ secrets.TELEGRAM_BOT_API_KEY }}" -var="resource_group=${{ vars.RESOURCE_GROUP }}" -detailed-exitcode -no-color -out tfplan || export exitcode=$?
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
Expand All @@ -90,7 +93,7 @@ jobs:
- name: Create String Output
id: tf-plan-string
run: |
TERRAFORM_PLAN=$(terraform -chdir=infra show -no-color tfplan)
TERRAFORM_PLAN=$(terraform show -no-color tfplan)
delimiter="$(openssl rand -hex 8)"
echo "summary<<${delimiter}" >> $GITHUB_OUTPUT
Expand All @@ -110,12 +113,12 @@ jobs:
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
- name: Terraform Apply
run: terraform -chdir=infra apply -input=false -auto-approve tfplan
run: terraform apply -input=false -auto-approve tfplan

- name: Get Terraform Outputs
id: terraformOutputsStep
run: |
echo "FUNCTIONS_APP_NAME=$(terraform -chdir=infra output -raw function_app_name)" >> "$GITHUB_OUTPUT"
echo "FUNCTIONS_APP_NAME=$(terraform output -raw function_app_name)" >> "$GITHUB_OUTPUT"
build:
name: Build
Expand Down Expand Up @@ -147,7 +150,7 @@ jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [provision-infrastructure, build]
needs: [provision, build]
env:
FUNCTIONS_APP_NAME: ${{ needs.provision-infrastructure.outputs.functionAppName }}

Expand Down
9 changes: 2 additions & 7 deletions build-github-actions/act-cli.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
docker build -t my-build-server:latest ./build-github-actions

act \
-W ".github/workflows/provision-deploy.yml" \
-s GITHUB_TOKEN="$(gh auth token)" \
-P ubuntu-latest=my-build-server:latest \
--secret-file my.secrets \
--artifact-server-path act-cli-temp-artifacts \
--var-file configurationVariables.secrets
# Act CLI docs: https://nektosact.com/usage/index.html
clear | act -W ".github/workflows/provision-deploy.yml" -s GITHUB_TOKEN="$(gh auth token)" -P ubuntu-latest=my-build-server:latest --secret-file my.secrets --artifact-server-path act-cli-temp-artifacts --var-file configurationVariables.secrets --pull=false # -j 'provision'

0 comments on commit 25444cd

Please sign in to comment.