From 0f37d7f73966a6ea8faeb5a5eda2f0b30889d81e Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Thu, 8 Feb 2024 14:34:25 +1100 Subject: [PATCH] Updated references to called deploy-1-setup.yml with the new ref, version inputs (#46) * Updated references to called deploy-1-setup.yml with the new ref, version inputs * cd.yml: Made the deployment ref more generic than just main --- .github/workflows/cd.yml | 1 + .github/workflows/ci.yml | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 8963e15..63d1fce 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -56,6 +56,7 @@ jobs: - generate-tag uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@main with: + ref: ${{ github.ref_name }} version: ${{ needs.generate-tag.outputs.name }} secrets: inherit permissions: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72aff2c..0ffed97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,16 +139,23 @@ jobs: needs: - branch-check outputs: - number: ${{ steps.history.outputs.commits }} + number: ${{ steps.get-version.outputs.number }} steps: - uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} fetch-depth: 0 - - name: Get Number of Commits on ${{ github.head_ref }} - id: history - run: echo "commits=$(git rev-list --count origin/main..HEAD)" >> $GITHUB_OUTPUT + - name: Generate Version Number + id: get-version + # This step generates the version number for prereleases, which given a branch + # like `pre-`, looks like: `-`. + # Ex. `pre-2024.10.1` with 2 commits on branch -> `2024.10.1-2`. + run: | + number_of_commits=$(git rev-list --count origin/main..HEAD) + no_pre_version=$(cut --delimiter '-' --field 2 <<< "${{ github.head_ref }}") + echo "number=${no_pre_version}-${number_of_commits}" >> $GITHUB_OUTPUT + prerelease-deploy: name: Deploy to Prerelease @@ -170,5 +177,6 @@ jobs: uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@main with: type: prerelease - version: ${{ github.head_ref }}-${{ needs.prerelease-deploy-version.outputs.number }} + ref: ${{ github.head_ref }} + version: ${{ needs.prerelease-deploy-version.outputs.number }} secrets: inherit