-
Notifications
You must be signed in to change notification settings - Fork 2
CCM-16035 Update deploy worfklow #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4388af2
4da65f7
d786128
e748c54
63e104a
b8582e3
0122454
2341b87
4b9857b
6c935b3
37e3389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,112 +3,72 @@ name: "2. CD - Deploy" | |
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| include_prereleases: | ||
| source_type: | ||
| description: "Deployment source type" | ||
| type: choice | ||
| description: "Include pre-releases" | ||
| default: "true" | ||
| required: true | ||
| default: release | ||
| options: | ||
| - "true" | ||
| - "false" | ||
| version: | ||
| type: string | ||
| default: latest | ||
| description: "Install specific version" | ||
| - release | ||
| - branch | ||
| source_value: | ||
| description: "Release tag or branch name" | ||
| type: string | ||
| required: true | ||
| deploy_backend: | ||
| description: "Deploy backend infrastructure" | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| backend_account_group: | ||
| description: "Target backend account group" | ||
| type: choice | ||
| required: true | ||
| default: dev | ||
| options: | ||
| - dev | ||
| - nonprod | ||
| - prod | ||
| deploy_proxy: | ||
| description: "Deploy APIM proxy" | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| apim_environment: | ||
| description: "Target APIM environment" | ||
| type: choice | ||
| required: true | ||
| default: internal-dev | ||
| options: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still use ref? |
||
| - internal-dev | ||
| - int | ||
| - prod | ||
| build_sandbox: | ||
| description: "Build sandbox container" | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
|
|
||
| run-name: >- | ||
| Deploy ${{ inputs.deploy_backend && format('backend={0}', | ||
| inputs.backend_account_group) || '' }} ${{ inputs.deploy_proxy && | ||
| format('apim={0}', inputs.apim_environment) || '' }} source=${{ | ||
| inputs.source_type }}:${{ inputs.source_value }} by @${{ github.actor }} | ||
|
|
||
| run-name: "Include prerelease: ${{ inputs.include_prereleases }} Version: ${{ inputs.version }} by @${{ github.actor }}" | ||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
| contents: read | ||
| packages: read | ||
|
|
||
| jobs: | ||
| metadata: | ||
| name: "Set CI/CD metadata" | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 1 | ||
| outputs: | ||
| build_datetime: ${{ steps.variables.outputs.build_datetime }} | ||
| build_timestamp: ${{ steps.variables.outputs.build_timestamp }} | ||
| build_epoch: ${{ steps.variables.outputs.build_epoch }} | ||
| nodejs_version: ${{ steps.variables.outputs.nodejs_version }} | ||
| python_version: ${{ steps.variables.outputs.python_version }} | ||
| terraform_version: ${{ steps.variables.outputs.terraform_version }} | ||
| version: ${{ steps.variables.outputs.version }} | ||
| # tag: ${{ steps.variables.outputs.tag }} | ||
| steps: | ||
| - name: "Checkout code" | ||
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | ||
| - name: "Set CI/CD variables" | ||
| id: variables | ||
| run: | | ||
| datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z') | ||
| echo "build_datetime=$datetime" >> $GITHUB_OUTPUT | ||
| echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | ||
| echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT | ||
| echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT | ||
| echo "python_version=$(grep "^python\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT | ||
| echo "terraform_version=$(grep "^terraform\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT | ||
| echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT | ||
| # echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | ||
| - name: "List variables" | ||
| run: | | ||
| export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}" | ||
| export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}" | ||
| export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}" | ||
| export NODEJS_VERSION="${{ steps.variables.outputs.nodejs_version }}" | ||
| export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}" | ||
| export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}" | ||
| export VERSION="${{ steps.variables.outputs.version }}" | ||
| # export TAG="${{ steps.variables.outputs.tag }}" | ||
| make list-variables | ||
|
|
||
| deploy-jekyll: | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| needs: metadata | ||
| steps: | ||
| - name: "Checkout code" | ||
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | ||
| - name: "Get version" | ||
| id: get-asset-version | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| if [[ ${{inputs.include_prereleases}} == true ]]; then | ||
| json=$(gh release list --json tagName --limit 1 --exclude-drafts) | ||
| else | ||
| json=$(gh release list --json tagName --limit 1 --exclude-drafts --exclude-pre-releases) | ||
| fi | ||
|
|
||
| echo $json | ||
|
|
||
| release_version=$(echo $json | (jq -r '.[0].tagName')) | ||
| if [[ $release_version == null ]]; then exit 1; else echo $release_version; fi | ||
|
|
||
| if [[ ${{inputs.version}} == latest ]]; then | ||
| echo release_version=$(echo $release_version) >> $GITHUB_OUTPUT | ||
| else | ||
| echo release_version=$(echo ${{inputs.version}}) >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: "Get release version" | ||
| id: download-asset | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| gh release download ${{steps.get-asset-version.outputs.release_version}} -p jekyll-docs-*.tar --output artifact.tar | ||
|
|
||
| - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 | ||
| with: | ||
| name: jekyll-docs-${{steps.get-asset-version.outputs.release_version}} | ||
| path: artifact.tar | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we want to get rid of deploying these pages? Discussion was that we are already doing this on publish, but publish doesn't deploy the docs to github pages - unless we don't want to do that anymore |
||
| with: | ||
| artifact_name: jekyll-docs-${{steps.get-asset-version.outputs.release_version}} | ||
| deploy: | ||
| uses: ./.github/workflows/deploy-supplier-api.yaml | ||
| secrets: inherit | ||
| with: | ||
| backend_account_group: ${{ inputs.backend_account_group }} | ||
| apim_environment: ${{ inputs.apim_environment }} | ||
| source_type: ${{ inputs.source_type }} | ||
| source_value: ${{ inputs.source_value }} | ||
| deploy_backend: ${{ inputs.deploy_backend }} | ||
| deploy_proxy: ${{ inputs.deploy_proxy }} | ||
| build_sandbox: ${{ inputs.build_sandbox }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Deploy backend only | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| backend_account_group: | ||
| description: "Target backend account group" | ||
| type: choice | ||
| required: true | ||
| default: dev | ||
| options: | ||
| - dev | ||
| - nonprod | ||
| - prod | ||
| source_type: | ||
| description: "Deployment source type" | ||
| type: choice | ||
| required: true | ||
| default: release | ||
| options: | ||
| - release | ||
| - branch | ||
| source_value: | ||
| description: "Release tag or branch name" | ||
| type: string | ||
| required: true | ||
|
|
||
| run-name: >- | ||
| Deploy backend=${{ inputs.backend_account_group }} source=${{ | ||
| inputs.source_type }}:${{ inputs.source_value }} by @${{ github.actor }} | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| packages: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| uses: ./.github/workflows/deploy-supplier-api.yaml | ||
| secrets: inherit | ||
| with: | ||
| backend_account_group: ${{ inputs.backend_account_group }} | ||
| source_type: ${{ inputs.source_type }} | ||
| source_value: ${{ inputs.source_value }} | ||
| deploy_backend: true | ||
| deploy_proxy: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: Deploy proxy only | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| apim_environment: | ||
| description: "Target APIM environment" | ||
| type: choice | ||
| required: true | ||
| default: internal-dev | ||
| options: | ||
| - internal-dev | ||
| - int | ||
| - prod | ||
| source_type: | ||
| description: "Deployment source type" | ||
| type: choice | ||
| required: true | ||
| default: release | ||
| options: | ||
| - release | ||
| - branch | ||
| source_value: | ||
| description: "Release tag or branch name" | ||
| type: string | ||
| required: true | ||
| build_sandbox: | ||
| description: "Build sandbox container" | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
|
|
||
| run-name: >- | ||
| Deploy proxy apim=${{ inputs.apim_environment }} source=${{ inputs.source_type | ||
| }}:${{ inputs.source_value }} by @${{ github.actor }} | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| packages: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| uses: ./.github/workflows/deploy-supplier-api.yaml | ||
| secrets: inherit | ||
| with: | ||
| apim_environment: ${{ inputs.apim_environment }} | ||
| source_type: ${{ inputs.source_type }} | ||
| source_value: ${{ inputs.source_value }} | ||
| deploy_backend: false | ||
| deploy_proxy: true | ||
| build_sandbox: ${{ inputs.build_sandbox }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there's no approvals step for nonprod deployments (as in prod). If I accidentally deploy something to nonprod via https://github.com/NHSDigital/nhs-notify-internal/actions/workflows/dispatch-deploy-static-notify-supplier-api-env.yaml (or this new deploy worflow) and it passes, it will be deployed...