Skip to content

Hardcode 34c63f1 for testing API #2378

Hardcode 34c63f1 for testing API

Hardcode 34c63f1 for testing API #2378

Workflow file for this run

name: "[Workflow] PR"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
defaults:
run:
shell: bash
on:
pull_request:
branches:
- main
permissions:
contents: write
security-events: write
pull-requests: read
actions: none
checks: none
deployments: none
issues: none
packages: none
repository-projects: none
statuses: none
jobs:
workspace_name:
uses: ministryofjustice/opg-github-workflows/.github/workflows/data-parse-workspace.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
image_tag:
name: Generate image tags
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.short_sha.outputs.short_sha }}
steps:
- name: Set output to short SHA
id: short_sha
env:
HEAD_GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
run: echo "short_sha=${HEAD_GITHUB_SHA::7}" >> $GITHUB_OUTPUT
terraform_lint:
name: TF - Lint
uses: ministryofjustice/opg-github-workflows/.github/workflows/linting-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
with:
terraform_version: 1.1.2
phpunit_tests:
name: Run PHPUnit tests
uses: ./.github/workflows/phpunit.yml
secrets: inherit
docker_build_scan_push:
name: Docker Build, Scan and Push
uses: ./.github/workflows/docker_job.yml
needs:
- image_tag
with:
tag: ${{ needs.image_tag.outputs.short_sha }}
secrets: inherit
terraform_account_development:
name: TF Development - Account
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- terraform_lint
with:
terraform_version: 1.1.2
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
workspace_manager_aws_iam_role: opg-lpa-ci
terraform_apply: true
terraform_directory: ./terraform/account
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_region_development:
name: TF Development - Region
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- terraform_lint
with:
terraform_version: 1.1.2
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
workspace_manager_aws_iam_role: opg-lpa-ci
terraform_apply: true
terraform_directory: ./terraform/region
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_email_development:
name: TF Development - Email
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- terraform_lint
with:
terraform_version: 1.1.2
terraform_workspace: development
is_ephemeral: false
workspace_manager_aws_account_id: "050256574573"
workspace_manager_aws_iam_role: opg-lpa-ci
terraform_apply: true
terraform_directory: ./terraform/email
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_environment_development:
name: TF Development - Environment
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- docker_build_scan_push
- phpunit_tests
- workspace_name
- image_tag
- terraform_email_development
- terraform_account_development
- terraform_region_development
with:
terraform_version: 1.1.2
use_ssh_private_key: true
terraform_workspace: ${{ needs.workspace_name.outputs.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.image_tag.outputs.short_sha }} -var lambda_container_version=latest"
persist_artifacts: true
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_account_preproduction:
name: TF Preproduction Plan - Account
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- image_tag
- terraform_lint
with:
terraform_version: 1.1.2
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/account
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_region_preproduction:
name: TF Preproduction Plan - Region
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- image_tag
- terraform_lint
with:
terraform_version: 1.1.2
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/region
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
terraform_environment_preproduction:
name: TF Preproduction Plan - Environment
uses: ministryofjustice/opg-github-workflows/.github/workflows/build-infrastructure-terraform.yml@383650d409aad063a69ce6cc3a013ac538cc1508 # v1.16.0
needs:
- workspace_name
- image_tag
- terraform_lint
with:
terraform_version: 1.1.2
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.image_tag.outputs.short_sha }} -var lambda_container_version=latest"
secrets:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
AWS_ACCESS_KEY_ID_ACTIONS: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
AWS_SECRET_ACCESS_KEY_ACTIONS: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run_dev_seed_db_task:
name: Run development DB seeding
uses: ./.github/workflows/workflow_start_task.yml
with:
account_id: "050256574573"
task_name: "seeding"
needs:
- terraform_environment_development
secrets: inherit
terraform_outputs:
name: Render terraform outputs
runs-on: ubuntu-latest
needs:
- run_dev_seed_db_task
- terraform_environment_development
outputs:
admin_fqdn: ${{ steps.admin_fqdn.outputs.value }}
front_fqdn: ${{ steps.front_fqdn.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Download Terraform Task definition
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # tag=v3.0.2
with:
name: terraform-artifact
path: /tmp/
- name: Set environment variable
id: set_var
run: |
content=$(cat /tmp/environment_pipeline_tasks_config.json)
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "configJson=${content}" >> $GITHUB_OUTPUT
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ACTIONS }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }}
aws-region: eu-west-1
role-to-assume: arn:aws:iam::050256574573:role/opg-lpa-ci
role-duration-seconds: 900
role-session-name: OPGLPABuildPipeline
- name: Extract Admin FQDN from JSON
id: admin_fqdn
env:
configJson: ${{steps.set_var.outputs.configJson}}
run: |
echo "value=${{ fromJson(env.configJson).admin_fqdn }}" >> $GITHUB_OUTPUT
- name: Extract Front FQDN from JSON
id: front_fqdn
run: |
echo "value=${{ fromJson(steps.set_var.outputs.configJson).front_fqdn }}" >> $GITHUB_OUTPUT
post_deployment_slack_msg:
name: Post-Deployment Slack message
runs-on: ubuntu-latest
outputs:
ts: ${{ steps.slack.outputs.ts }}
needs:
- terraform_outputs
- image_tag
env:
FRONT_URL: ${{ needs.terraform_outputs.outputs.front_fqdn }}
ADMIN_URL: ${{ needs.terraform_outputs.outputs.admin_fqdn }}
steps:
- name: Login to Jira
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # tag=3.0.1
continue-on-error: true
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Find in commit messages
uses: atlassian/gajira-find-issue-key@7d11fdc500b3b69d3edd797e9f1d619b89f8dafc # tag=3.0.1
continue-on-error: true
id: jira_ticket
with:
string: ${{ github.event.pull_request.title }}
- uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
id: slack
with:
channel-id: "C01BKBWGWTY"
payload: |
{
"icon_emoji": ":robot_face:",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Development Environment Deployment",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Status:*\nDeployed (Tests running)"
},
{
"type": "mrkdwn",
"text": "*Started by:*\n ${{ github.triggering_actor }}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.image_tag.outputs.short_sha }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/ministryofjustice/opg-lpa/actions/runs/${{github.run_id}}|View workflow>"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Front URL:* https://${{ env.FRONT_URL }}/home\n*Admin URL:* https://${{ env.ADMIN_URL }}\n*Jira Ticket:* https://opgtransform.atlassian.net/browse/${{ steps.jira_ticket.outputs.issue }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
cypress_tests_Signup_StichedPF:
name: Run Cypress tests - @Signup,@StitchedPF
uses: ./.github/workflows/cypress_tests.yml
needs:
- terraform_outputs
with:
admin_url: https://${{ needs.terraform_outputs.outputs.admin_fqdn }}
front_url: https://${{ needs.terraform_outputs.outputs.front_fqdn }}
account_id: "050256574573"
cypress_tags: "@Signup,@StitchedPF"
secrets: inherit
cypress_tests_Signup_StichedHW:
name: Run Cypress tests - @Signup,@StitchedHW
uses: ./.github/workflows/cypress_tests.yml
needs:
- terraform_outputs
with:
admin_url: https://${{ needs.terraform_outputs.outputs.admin_fqdn }}
front_url: https://${{ needs.terraform_outputs.outputs.front_fqdn }}
account_id: "050256574573"
cypress_tags: "@Signup,@StitchedHW"
secrets: inherit
cypress_tests_Signup_StichedClone:
name: Run Cypress tests - @Signup,@StitchedClone
uses: ./.github/workflows/cypress_tests.yml
needs:
- terraform_outputs
with:
admin_url: https://${{ needs.terraform_outputs.outputs.admin_fqdn }}
front_url: https://${{ needs.terraform_outputs.outputs.front_fqdn }}
account_id: "050256574573"
cypress_tags: "@Signup,@StitchedClone"
secrets: inherit
cypress_tests_SignupIncluded:
name: Run Cypress tests - @SignupIncluded
uses: ./.github/workflows/cypress_tests.yml
needs:
- terraform_outputs
with:
admin_url: https://${{ needs.terraform_outputs.outputs.admin_fqdn }}
front_url: https://${{ needs.terraform_outputs.outputs.front_fqdn }}
account_id: "050256574573"
cypress_tags: "@SignupIncluded"
secrets: inherit
# Remaining tests should ultimately just exclude SignUp and anything already done as part of stitched run.
# TODO CorrespondentReuse needs refactoring so that it can be included as part of the stitchedClone run.
cypress_tests_Remaining:
name: Run Cypress tests - Remaining
uses: ./.github/workflows/cypress_tests.yml
needs:
- terraform_outputs
with:
admin_url: https://${{ needs.terraform_outputs.outputs.admin_fqdn }}
front_url: https://${{ needs.terraform_outputs.outputs.front_fqdn }}
account_id: "050256574573"
cypress_tags: "@Signup,not @Signup and not @PartOfStitchedRun and not @StitchedHW and not @StitchedPF and not @StitchedClone and not @CorrespondentReuse and not @SignupIncluded and not @AdminSystemMessage and not @CheckoutPaymentGateway"
secrets: inherit
post_tests_slack_msg:
name: Post-Tests Slack message
runs-on: ubuntu-latest
needs:
- terraform_outputs
- image_tag
- post_deployment_slack_msg
- cypress_tests_Remaining
- cypress_tests_SignupIncluded
- cypress_tests_Signup_StichedClone
- cypress_tests_Signup_StichedHW
- cypress_tests_Signup_StichedPF
env:
FRONT_URL: ${{ needs.terraform_outputs.outputs.front_fqdn }}
ADMIN_URL: ${{ needs.terraform_outputs.outputs.admin_fqdn }}
steps:
- name: Login to Jira
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # tag=3.0.1
continue-on-error: true
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Find in commit messages
uses: atlassian/gajira-find-issue-key@master
id: jira_ticket
continue-on-error: true
with:
string: ${{ github.event.pull_request.title }}
- uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
channel-id: "C01BKBWGWTY"
update-ts: ${{ needs.post_deployment_slack_msg.outputs.ts }}
payload: |
{
"icon_emoji": ":robot_face:",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Development Environment Deployment",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Status:*\nDeployed (Tests have passed!)"
},
{
"type": "mrkdwn",
"text": "*Started by:*\n ${{ github.triggering_actor }}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit:*\n <https://github.com/ministryofjustice/opg-lpa/commit/${{ github.sha }}|${{ needs.image_tag.outputs.short_sha }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/ministryofjustice/opg-lpa/actions/runs/${{github.run_id}}|View workflow>"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Front URL:* https://${{ env.FRONT_URL }}/home\n*Admin URL:* https://${{ env.ADMIN_URL }}\n*Jira Ticket:* https://opgtransform.atlassian.net/browse/${{ steps.jira_ticket.outputs.issue }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
end_of_pr_workflow:
name: End of PR Workflow
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- cypress_tests_Remaining
- cypress_tests_SignupIncluded
- cypress_tests_Signup_StichedClone
- cypress_tests_Signup_StichedHW
- cypress_tests_Signup_StichedPF
- workspace_name
- terraform_outputs
- image_tag
environment:
name: "dev_${{ needs.workspace_name.outputs.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.image_tag.outputs.short_sha }}"
echo "URL: https://${{ env.FRONT_URL }}/home"