|
| 1 | +name: release workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +env: |
| 8 | + BRANCH_NAME: ${{ github.ref_name }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + get_commit_id: |
| 12 | + runs-on: ubuntu-22.04 |
| 13 | + outputs: |
| 14 | + commit_id: ${{ steps.commit_id.outputs.commit_id }} |
| 15 | + sha_short: ${{ steps.commit_id.outputs.sha_short }} |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v5 |
| 20 | + with: |
| 21 | + ref: ${{ env.BRANCH_NAME }} |
| 22 | + |
| 23 | + - name: Get Commit ID |
| 24 | + id: commit_id |
| 25 | + run: | |
| 26 | + # echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV" |
| 27 | + echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT" |
| 28 | + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 29 | + get_asdf_version: |
| 30 | + runs-on: ubuntu-22.04 |
| 31 | + outputs: |
| 32 | + asdf_version: ${{ steps.asdf-version.outputs.version }} |
| 33 | + tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }} |
| 34 | + steps: |
| 35 | + - name: Checkout code |
| 36 | + uses: actions/checkout@v5 |
| 37 | + |
| 38 | + - name: Get asdf version |
| 39 | + id: asdf-version |
| 40 | + run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT" |
| 41 | + - name: Load config value |
| 42 | + id: load-config |
| 43 | + run: | |
| 44 | + TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml) |
| 45 | + echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT" |
| 46 | + quality_checks: |
| 47 | + uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@4a6d03ad51516eddc448daf454805f85fe2025b9 |
| 48 | + needs: [get_asdf_version, get_commit_id] |
| 49 | + with: |
| 50 | + asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }} |
| 51 | + secrets: |
| 52 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 53 | + |
| 54 | + tag_release: |
| 55 | + needs: [quality_checks, get_commit_id, get_asdf_version] |
| 56 | + uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@7c0d0e06afc120ec47372b479aa147ff9b453bca |
| 57 | + with: |
| 58 | + dry_run: true |
| 59 | + asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }} |
| 60 | + branch_name: main |
| 61 | + publish_package: true |
| 62 | + tag_format: ${{ needs.get_asdf_version.outputs.tag_format }} |
| 63 | + secrets: inherit |
| 64 | + |
| 65 | + package_code: |
| 66 | + needs: [tag_release, quality_checks, get_commit_id] |
| 67 | + uses: ./.github/workflows/docker_image_build.yml |
| 68 | + with: |
| 69 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 70 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 71 | + |
| 72 | + release_dev: |
| 73 | + needs: [tag_release, package_code, get_commit_id] |
| 74 | + uses: ./.github/workflows/docker_image_upload.yml |
| 75 | + with: |
| 76 | + AWS_ENVIRONMENT: dev |
| 77 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 78 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 79 | + TAG_LATEST: true |
| 80 | + DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
| 81 | + secrets: |
| 82 | + CDK_PUSH_IMAGE_ROLE: ${{ secrets.DEV_CDK_PUSH_IMAGE_ROLE }} |
| 83 | + |
| 84 | + release_qa: |
| 85 | + needs: [tag_release, release_dev, package_code, get_commit_id] |
| 86 | + uses: ./.github/workflows/docker_image_upload.yml |
| 87 | + with: |
| 88 | + AWS_ENVIRONMENT: qa |
| 89 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 90 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 91 | + TAG_LATEST: true |
| 92 | + DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
| 93 | + secrets: |
| 94 | + CDK_PUSH_IMAGE_ROLE: ${{ secrets.QA_CDK_PUSH_IMAGE_ROLE }} |
| 95 | + |
| 96 | + release_ref: |
| 97 | + needs: [tag_release, release_dev, package_code, get_commit_id] |
| 98 | + uses: ./.github/workflows/docker_image_upload.yml |
| 99 | + with: |
| 100 | + AWS_ENVIRONMENT: ref |
| 101 | + VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 102 | + COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }} |
| 103 | + TAG_LATEST: true |
| 104 | + DOCKER_IMAGE_TAG: ${{needs.tag_release.outputs.version_tag}} |
| 105 | + secrets: |
| 106 | + CDK_PUSH_IMAGE_ROLE: ${{ secrets.REF_CDK_PUSH_IMAGE_ROLE }} |
0 commit comments