Skip to content

Post Publish

Post Publish #220

Workflow file for this run

name: Post Publish
on:
workflow_dispatch:
inputs:
release-tag:
type: string
description: 'Semver release tag e.g. v1.1.0'
required: true
workflow_run:
workflows: [Release]
types:
- completed
jobs:
on-success-or-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch'
outputs:
release-tag: ${{ steps.release-tag.outputs.tag }}
steps:
- if: github.event_name == 'workflow_run'
name: Download Artifact from Release workflow
uses: dawidd6/action-download-artifact@80620a5d27ce0ae443b965134db88467fc607b43 # v7
with:
workflow: release.yml
name: release-tag
- name: Output Release Tag
id: release-tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ github.event.inputs.release-tag }}" >> "$GITHUB_OUTPUT"
else
value=`cat release-tag.data`
echo "tag=$value" >> "$GITHUB_OUTPUT"
fi
tidy-jira:
needs: [on-success-or-workflow-dispatch]
runs-on: ubuntu-latest
steps:
- name: Tidy Jira
uses: breathingdust/github-jira-tidy@b503407f09af5564fd806924bdf4495510d848b6 # v0.10.0
with:
jira_host: 'hashicorp.atlassian.net'
jira_username: 'sdavis@hashicorp.com'
jira_password: ${{ secrets.jira_password }}
jira_jql_filter: ${{ secrets.jira_jql_filter }}
jira_github_url_field_id: 'cf[10089]'
github_release_name: ${{ needs.on-success-or-workflow-dispatch.outputs.release-tag }}
github_token: ${{ secrets.GITHUB_TOKEN }}
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
registry-check:
runs-on: ubuntu-latest
needs: [on-success-or-workflow-dispatch]
outputs:
latest-version: ${{ steps.registry_latest_ver.outputs.current }}
steps:
- name: Registry Version Check
id: registry_latest_ver
shell: bash
run: |
for i in 1 2
do
LATEST_VERSION=$(curl -s "https://registry.terraform.io/v2/providers/323/provider-versions/latest" | jq -r '.data.attributes.version')
if [[ "${{ needs.on-success-or-workflow-dispatch.outputs.release-tag }}" != "v${LATEST_VERSION}" ]]; then
sleep 1h
else
echo "Registry and Github Version matches"
echo "current=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "Registry does not contain ${{ needs.on-success-or-workflow-dispatch.outputs.release-tag }}"
exit 1
os-version-init:
name: Run terraform init On Supported Platforms
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
needs: [registry-check]
steps:
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_wrapper: false
- name: Specify Provider Version in TF Configuration
run: |
cat <<EOF > main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "${{ needs.registry-check.outputs.latest-version }}"
}
}
}
provider "aws" {
region = "us-east-1"
}
EOF
- name: Initialize the AWS Provider
run: terraform init -upgrade
- name: Send Slack Notification Upon Failure
if: ${{ failure() }}
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel" : "${{ secrets.SLACK_CHANNEL }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "ERROR: Registry Provder Initiation Failure on ${{ matrix.os }}"
}
}
]
}