Skip to content

Commit

Permalink
LPAL-1320: upgrade to branch-name (#2160)
Browse files Browse the repository at this point in the history
* LPAL-1320: upgrade to branch-name

* rename set_variables
  • Loading branch information
jay-whitwell authored Oct 17, 2024
1 parent 2405295 commit 8c06ffb
Showing 1 changed file with 38 additions and 41 deletions.
79 changes: 38 additions & 41 deletions .github/workflows/workflow_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ permissions:
statuses: none

jobs:
workspace_name:
uses: ministryofjustice/opg-github-workflows/.github/workflows/data-parse-workspace.yml@bd6ac6106a4adda64cecefa3632fb64ab0ddab4b # v1.36.0

set_variables:
name: Generate image tags
workflow_variables:
name: Output workflow variables
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.short_sha.outputs.short_sha }}
safe_branch_name: ${{ steps.safe_branch_name.outputs.safe }}
environment_terraform_version: ${{ steps.terraform_version_environment.outputs.version }}
account_terraform_version: ${{ steps.terraform_version_account.outputs.version }}
region_terraform_version: ${{ steps.terraform_version_region.outputs.version }}
email_terraform_version: ${{ steps.terraform_version_email.outputs.version }}
steps:
- name: Set safe branch name
id: safe_branch_name
uses: ministryofjustice/opg-github-actions/.github/actions/[email protected]
with:
length: "15"

- name: Set output to short SHA
id: short_sha
env:
Expand Down Expand Up @@ -69,10 +74,10 @@ jobs:
terraform_lint:
name: TF - Lint
needs:
- set_variables
- workflow_variables
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
with:
terraform_version: ${{ needs.set_variables.outputs.environment_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.environment_terraform_version }}

phpunit_tests:
name: Run PHPUnit tests
Expand All @@ -83,20 +88,19 @@ jobs:
name: Docker Build, Scan and Push
uses: ./.github/workflows/docker_job.yml
needs:
- set_variables
- workflow_variables
with:
tag: ${{ needs.set_variables.outputs.short_sha }}
tag: ${{ needs.workflow_variables.outputs.short_sha }}
secrets: inherit

terraform_account_development:
name: TF Development - Account
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- terraform_lint
- set_variables
- workflow_variables
with:
terraform_version: ${{ needs.set_variables.outputs.account_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.account_terraform_version }}
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
Expand All @@ -114,11 +118,10 @@ jobs:
name: TF Development - Region
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- terraform_lint
- set_variables
- workflow_variables
with:
terraform_version: ${{ needs.set_variables.outputs.region_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.region_terraform_version }}
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
Expand All @@ -136,11 +139,10 @@ jobs:
name: TF Development - Email
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- terraform_lint
- set_variables
- workflow_variables
with:
terraform_version: ${{ needs.set_variables.outputs.email_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.email_terraform_version }}
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
Expand All @@ -160,21 +162,20 @@ jobs:
needs:
- docker_build_scan_push
- phpunit_tests
- workspace_name
- set_variables
- workflow_variables
- terraform_email_development
- terraform_account_development
- terraform_region_development
with:
terraform_version: ${{ needs.set_variables.outputs.environment_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.environment_terraform_version }}
use_ssh_private_key: true
terraform_workspace: ${{ needs.workspace_name.outputs.name }}
terraform_workspace: ${{ needs.workflow_variables.outputs.safe_branch_name }}
is_ephemeral: true
workspace_manager_aws_account_id: "050256574573"
workspace_manager_aws_iam_role: opg-lpa-ci
terraform_apply: true
terraform_directory: ./terraform/environment
terraform_variables: "-var container_version=${{ needs.set_variables.outputs.short_sha }}"
terraform_variables: "-var container_version=${{ needs.workflow_variables.outputs.short_sha }}"
persist_artifacts: true
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -187,11 +188,10 @@ jobs:
name: TF Preproduction Plan - Account
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- set_variables
- workflow_variables
- terraform_lint
with:
terraform_version: ${{ needs.set_variables.outputs.account_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.account_terraform_version }}
terraform_workspace: preproduction
is_ephemeral: false
workspace_manager_aws_account_id: "987830934591"
Expand All @@ -209,11 +209,10 @@ jobs:
name: TF Preproduction Plan - Region
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- set_variables
- workflow_variables
- terraform_lint
with:
terraform_version: ${{ needs.set_variables.outputs.region_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.region_terraform_version }}
terraform_workspace: preproduction
is_ephemeral: false
workspace_manager_aws_account_id: "987830934591"
Expand All @@ -231,19 +230,18 @@ jobs:
name: TF Preproduction Plan - Environment
uses: ministryofjustice/opg-github-workflows/.github/workflows/[email protected]
needs:
- workspace_name
- set_variables
- workflow_variables
- terraform_lint
with:
terraform_version: ${{ needs.set_variables.outputs.environment_terraform_version }}
terraform_version: ${{ needs.workflow_variables.outputs.environment_terraform_version }}
use_ssh_private_key: true
terraform_workspace: preproduction
is_ephemeral: false
workspace_manager_aws_account_id: "987830934591"
workspace_manager_aws_iam_role: opg-lpa-ci
terraform_apply: false
terraform_directory: ./terraform/environment
terraform_variables: "-var container_version=${{ needs.set_variables.outputs.short_sha }}"
terraform_variables: "-var container_version=${{ needs.workflow_variables.outputs.short_sha }}"
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
Expand Down Expand Up @@ -318,7 +316,7 @@ jobs:
ts: ${{ steps.slack.outputs.ts }}
needs:
- terraform_outputs
- set_variables
- workflow_variables
env:
FRONT_URL: ${{ needs.terraform_outputs.outputs.front_fqdn }}
ADMIN_URL: ${{ needs.terraform_outputs.outputs.admin_fqdn }}
Expand Down Expand Up @@ -357,7 +355,7 @@ jobs:
"fields": [
{
"type": "mrkdwn",
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.set_variables.outputs.short_sha }}>"
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.workflow_variables.outputs.short_sha }}>"
}
]
},
Expand Down Expand Up @@ -448,7 +446,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- terraform_outputs
- set_variables
- workflow_variables
- post_deployment_slack_msg
- cypress_tests_Remaining
- cypress_tests_SignupIncluded
Expand Down Expand Up @@ -494,7 +492,7 @@ jobs:
"fields": [
{
"type": "mrkdwn",
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.set_variables.outputs.short_sha }}>"
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.workflow_variables.outputs.short_sha }}>"
}
]
},
Expand Down Expand Up @@ -529,17 +527,16 @@ jobs:
- cypress_tests_Signup_StichedClone
- cypress_tests_Signup_StichedHW
- cypress_tests_Signup_StichedPF
- workspace_name
- terraform_outputs
- set_variables
- workflow_variables
environment:
name: "dev_${{ needs.workspace_name.outputs.name }}"
name: "dev_${{ needs.workflow_variables.outputs.safe_branch_name }}"
url: "https://${{ env.FRONT_URL }}/home"
env:
FRONT_URL: ${{ needs.terraform_outputs.outputs.front_fqdn }}
steps:
- name: End of PR Workflow
run: |
echo "${{ needs.workspace_name.outputs.name }} PR environment tested, built and deployed"
echo "Tag Deployed: ${{ needs.set_variables.outputs.short_sha }}"
echo "${{ needs.workflow_variables.outputs.safe_branch_name }} PR environment tested, built and deployed"
echo "Tag Deployed: ${{ needs.workflow_variables.outputs.short_sha }}"
echo "URL: https://${{ env.FRONT_URL }}/home"

0 comments on commit 8c06ffb

Please sign in to comment.