Bump braces from 3.0.2 to 3.0.3 #205
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: CI | |
on: | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
inputs: | |
stackName: | |
description: 'Pulumi stack name' | |
required: true | |
default: 'aws' | |
pulumiCommand: | |
description: 'Possible values are create, update or destroy' | |
default: 'update' | |
required: true | |
jobs: | |
turnstyle: | |
runs-on: ubuntu-latest | |
steps: | |
# Turnstyle is used to prevent multiple push jobs from | |
# running at the same time. | |
- name: Turnstyle | |
uses: softprops/turnstyle@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
infrastructure: | |
# Wait for turnstyle to allow this job to run. | |
needs: turnstyle | |
env: | |
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} | |
PULUMI_STACK_NAME: ${{ github.event.inputs.stackName }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get current time | |
uses: srfrnk/current-time@master | |
id: current-time | |
with: | |
# Get the day of week as Sat, Sun, Mon etc. | |
# This action uses MomentJS style syntax. | |
format: ddd | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "12" | |
- name: Install Pulumi CLI | |
uses: pulumi/[email protected] | |
- name: Restore npm dependencies | |
run: | | |
npm ci | |
echo "Restoring Azure Functions app dependencies..." | |
npm ci --prefix ./azure/functionapp | |
- name: Install Azure Functions Core Tools | |
run: | | |
# Install the Azure Functions Core Tools so that we can install | |
# the extension bundle for Azure Event Grid. | |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg | |
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg | |
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' | |
sudo apt-get update | |
sudo apt-get install azure-functions-core-tools | |
- name: Get stack outputs | |
id: set-stack-output | |
run: | | |
echo "::set-output name=stackOutput::$(pulumi stack output -s $PULUMI_STACK_NAME --json)" | |
# Always run a preview for pull_request events. | |
- name: Preview changes for all stacks | |
run: | | |
echo "Previewing AWS stack..." | |
npm run preview -- -s aws | |
echo "Previewing Azure stack..." | |
npm run buildAzFuncApp | |
npm run preview -- -s azure | |
if: github.event_name == 'pull_request' || steps.set-stack-output.outputs.stackOutput == '{}' | |
# Always run an update for a push build, IFF the stack already has resources. | |
- name: Update infrastructure | |
run: npm run ${PULUMI_STACK_NAME} -- --yes | |
if: github.event_name == 'workflow_dispatch' && steps.set-stack-output.outputs.stackOutput != '{}' && github.event.inputs.pulumiCommand == 'update' | |
# If this is a scheduled execution, and it is a Saturday, run the update to create the resources. | |
- name: Create infrastructure | |
run: npm run ${PULUMI_STACK_NAME} -- --yes | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.pulumiCommand == 'create' | |
# If this is a scheduled execution, and it is a Monday, destroy the resources. | |
- name: Destroy AWS infrastructure | |
if: env.PULUMI_STACK_NAME == 'aws' && github.event_name == 'workflow_dispatch' && github.event.inputs.pulumiCommand == 'destroy' | |
run: | | |
# First terminate the EC2 instance that fulfilled the Spot Instance Request (SIR). | |
# To do that, we should first query for the instance ID from the SIR. | |
SIR_ID=$(pulumi stack output spotRequestId -s "${PULUMI_STACK_NAME}") | |
echo "Spot Instance Request ID is ${SIR_ID}" | |
REGION=$(pulumi config get aws:region -s ${PULUMI_STACK_NAME}) | |
aws configure set region ${REGION} | |
DESCRIBE_SIR=$(aws ec2 describe-spot-instance-requests --spot-instance-request-ids "${SIR_ID}") | |
INSTANCE_ID=$(echo ${DESCRIBE_SIR} | jq '.SpotInstanceRequests[0].InstanceId' -c -r) | |
# Finally terminate the instance. | |
echo "Terminating the instance ${INSTANCE_ID}" | |
aws ec2 terminate-instances --instance-ids "${INSTANCE_ID}" | |
echo "Sleeping for 30s..." | |
sleep 30 | |
npm run destroy -- --yes -s ${PULUMI_STACK_NAME} | |
- name: Destroy Azure infrastructure | |
if: env.PULUMI_STACK_NAME == 'azure' && github.event_name == 'workflow_dispatch' && github.event.inputs.pulumiCommand == 'destroy' | |
run: npm run destroy -- --yes -s ${PULUMI_STACK_NAME} |