|
| 1 | +name: merge to main workflow |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +env: |
| 8 | + BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + quality_checks: |
| 12 | + uses: NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected] |
| 13 | + secrets: |
| 14 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 15 | + |
| 16 | + get_commit_id: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + commit_id: ${{ steps.commit_id.outputs.commit_id }} |
| 20 | + steps: |
| 21 | + - name: Get Commit ID |
| 22 | + id: commit_id |
| 23 | + run: | |
| 24 | + echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT" |
| 25 | +
|
| 26 | + tag_release: |
| 27 | + needs: quality_checks |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + version_tag: ${{ steps.output_version_tag.outputs.VERSION_TAG }} |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + ref: ${{ env.BRANCH_NAME }} |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + # using git commit sha for version of action to ensure we have stable version |
| 39 | + - name: Install asdf |
| 40 | + uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 |
| 41 | + with: |
| 42 | + asdf_branch: v0.14.1 |
| 43 | + |
| 44 | + - name: Cache asdf |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: | |
| 48 | + ~/.asdf |
| 49 | + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} |
| 50 | + restore-keys: | |
| 51 | + ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} |
| 52 | +
|
| 53 | + - name: Install asdf dependencies in .tool-versions |
| 54 | + uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6 |
| 55 | + with: |
| 56 | + asdf_branch: v0.14.1 |
| 57 | + env: |
| 58 | + PYTHON_CONFIGURE_OPTS: --enable-shared |
| 59 | + |
| 60 | + - name: Install Dependencies |
| 61 | + run: make install |
| 62 | + |
| 63 | + - name: Set VERSION_TAG env var to be short git SHA and get next tag varsion |
| 64 | + id: output_version_tag |
| 65 | + run: | |
| 66 | + VERSION_TAG=$(git rev-parse --short HEAD) |
| 67 | + npx semantic-release --dry-run > semantic-release-output.log |
| 68 | + NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/') |
| 69 | + if [ -z "${NEXT_VERSION}" ] |
| 70 | + then |
| 71 | + echo "Could not get next tag. Here is the log from semantic-release" |
| 72 | + cat semantic-release-output.log |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | + tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)") |
| 76 | + if [ "${tagFormat}" = "null" ] |
| 77 | + then |
| 78 | + tagFormat="v\${version}" |
| 79 | + fi |
| 80 | + # disabling shellcheck as replace does not work |
| 81 | + # shellcheck disable=SC2001 |
| 82 | + NEW_VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/") |
| 83 | + echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY" |
| 84 | + echo "## NEXT TAG WILL BE : ${NEW_VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY" |
| 85 | + echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT" |
| 86 | + echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV" |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ github.token }} |
| 89 | + |
| 90 | + # package_code: |
| 91 | + # needs: [tag_release, get_commit_id] |
| 92 | + # uses: ./.github/workflows/cdk_package_code.yml |
| 93 | + # with: |
| 94 | + # VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 95 | + # COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}} |
| 96 | + |
| 97 | + # release_dev: |
| 98 | + # needs: [tag_release, package_code, get_commit_id] |
| 99 | + # uses: ./.github/workflows/release_all_stacks.yml |
| 100 | + # with: |
| 101 | + # SERVICE_NAME: cpt-ui |
| 102 | + # TARGET_ENVIRONMENT: dev |
| 103 | + # VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 104 | + # COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}} |
| 105 | + # secrets: |
| 106 | + # CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }} |
| 107 | + # CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }} |
| 108 | + |
| 109 | + # create_release_notes: |
| 110 | + # needs: [tag_release, package_code, get_commit_id, release_dev] |
| 111 | + # uses: ./.github/workflows/create_release_notes.yml |
| 112 | + # with: |
| 113 | + # VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 114 | + # CREATE_INT_RELEASE_NOTES: true |
| 115 | + # CREATE_INT_RC_RELEASE_NOTES: false |
| 116 | + # CREATE_PROD_RELEASE_NOTES: true |
| 117 | + # MARK_JIRA_RELEASED: false |
| 118 | + # secrets: |
| 119 | + # DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE }} |
| 120 | + # DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE }} |
| 121 | + # INT_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.INT_CLOUD_FORMATION_CHECK_VERSION_ROLE }} |
| 122 | + # PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE: ${{ secrets.PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE }} |
| 123 | + |
| 124 | + |
| 125 | + # release_qa: |
| 126 | + # needs: [tag_release, release_dev, package_code, get_commit_id] |
| 127 | + # uses: ./.github/workflows/release_all_stacks.yml |
| 128 | + # with: |
| 129 | + # SERVICE_NAME: cpt-ui |
| 130 | + # TARGET_ENVIRONMENT: qa |
| 131 | + # VERSION_NUMBER: ${{needs.tag_release.outputs.version_tag}} |
| 132 | + # COMMIT_ID: ${{needs.get_commit_id.outputs.commit_id}} |
| 133 | + # secrets: |
| 134 | + # CDK_PULL_IMAGE_ROLE: ${{ secrets.QA_CDK_PULL_IMAGE_ROLE }} |
| 135 | + # CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.QA_CLOUD_FORMATION_DEPLOY_ROLE }} |
0 commit comments