diff --git a/.github/assets/nx-logo.png b/.github/assets/nx-logo.png new file mode 100644 index 0000000..30b58da Binary files /dev/null and b/.github/assets/nx-logo.png differ diff --git a/.github/assets/nx.png b/.github/assets/nx.png new file mode 100644 index 0000000..e862aa3 Binary files /dev/null and b/.github/assets/nx.png differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a734df --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* + +# Unplanned lock files +yarn.lock +pnpm-lock.yml + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Dependency directories +node_modules/ +jspm_packages/ + +# Compiled files +dist +tmp + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Yarn Integrity file +.yarn-integrity + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# IDE +.idea +.vscode + +.DS_Store \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0d99a10 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2021-present Narwhal Technologies Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 2ddfde8..7492024 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ -# nx-set-shas +

Nx - Smart, Extensible Build Framework

+ +

Set SHAs Action

+ +> ✨ A Github Action which sets the base and head SHAs required for `nx affected` commands in CI + +- [Example Usage](#example-usage) +- [Configuration Options](#configuration-options) +- [Background](#background) +- [License](#license) + +> This documentation is for version 2.x.x. You can find documentation for version 1.x.x [here](https://github.com/nrwl/nx-set-shas/blob/c8f5a54f6ee7f2127f3df063f36a0242faee4cb7/README.md). ## Example Usage @@ -25,7 +37,7 @@ jobs: # OPTION 1) Environment variables # =========================================================================== - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v1 + uses: nrwl/nx-set-shas@v2 - run: | echo "BASE: ${{ env.NX_BASE }}" @@ -36,7 +48,9 @@ jobs: # =========================================================================== - name: Derive appropriate SHAs for base and head for `nx affected` commands id: setSHAs - uses: nrwl/nx-set-shas@v1 + uses: nrwl/nx-set-shas@v2 + with: + set-environment-variables-for-job: 'false' - run: | echo "BASE: ${{ steps.setSHAs.outputs.base }}" @@ -58,22 +72,54 @@ jobs: # Default: main main-branch-name: '' - # The glob(7) pattern to be provided to `git describe --match` in order to match against - # the latest relevant tag on the specified "main" branch. - # - # The default pattern aligns with the default behavior of the complementary `nrwl/nx-tag-successful-ci-run` action. - # - # Default: nx_successful_ci_run* - tag-match-pattern: '' - # Applies the derived SHAs for base and head as NX_BASE and NX_HEAD environment variables within the current Job. # # Default: true set-environment-variables-for-job: '' - # By default, if no matching tags are found on the main branch to determine the SHA, we will log a warning and use HEAD~1. Enable this option to error and exit instead. + # By default, if no successful workflow run is found on the main branch to determine the SHA, we will log a warning and use HEAD~1. Enable this option to error and exit instead. # # Default: false - error-on-no-matching-tags: '' + error-on-no-successful-workflow: '' + + # The ID of the github action workflow to check for successful run or the name of the file name containing the workflow. + # E.g. 'ci.yml'. If not provided, current workflow id will be used + # + workflow-id: '' ``` - \ No newline at end of file + + +## Background + +When we run `affected` command on [Nx](https://nx.dev/), we can specify 2 git history positions - base and head, and it calculates [which projects in your repository changed +between those 2 commits](https://nx.dev/latest/angular/tutorial/11-test-affected-projects#step-11-test-affected-projects +). We can then run a set of tasks (like building or linting) only on those **affected** projects. + +This makes it easy to set-up a CI system that scales well with the continous growth of your repository, as you add more and more projects. + + +### Problem + +Figuring out what these two git commits are might not be as simple as it seems. + +On a CI system that runs on submitted PRs, we determine what commits to include in the **affected** calculation by comparing our `HEAD-commit-of-PR-branch` to the commit in main branch (`master` or `main` usually) from which the PR branch originated. This will ensure the entirety of our PR is always being tested. + +But what if we want to set up a continuous deployment system +that, as changes get pushed to `master`, it builds and deploys +only the affected projects? + +What are the `FROM` and `TO` commits in that case? + +Conceptually, what we want is to use the absolute latest commit on the `master` branch as the HEAD, and the previous _successful_ commit on `master` as the BASE. Note, we want the previous _successful_ one because it is still possible for commits on the `master` branch to fail for a variety of reasons. + +The commits therefore can't just be `HEAD` and `HEAD~1`. If a few deployments fail one after another, that means that we're accumulating a list of affected projects that are not getting deployed. Anytime we retry the deployment, we want to include **every commit since the last time we deployed successfully**. That way we ensure we don't accidentally skip deploying a project that has changed. + +This action enables you to find: +* Commit SHA from which PR originated (in the case of `pull_request`) +* Commit SHA of the last successful CI run + +## License + +[MIT](http://opensource.org/licenses/MIT) + +Copyright (c) 2021-present Narwhal Technologies Inc. diff --git a/action.yml b/action.yml index 6b3b088..81cc879 100644 --- a/action.yml +++ b/action.yml @@ -1,18 +1,17 @@ -name: 'Nx set SHAs' -description: 'Derives appropriate SHAs for base and head for use in `nx affected` commands, optionally setting them as environment variables for the current job' +name: "Nx set SHAs" +description: "Derives appropriate SHAs for base and head for use in `nx affected` commands, optionally setting them as environment variables for the current job" inputs: main-branch-name: - description: 'The name of the main branch in your repo, used as the target of PRs. E.g. main, master etc' - default: 'main' - tag-match-pattern: - description: 'The glob(7) pattern to be provided to `git describe --match` in order to match against the latest relevant tag on the specified main branch' - default: 'nx_successful_ci_run*' + description: "The name of the main branch in your repo, used as the target of PRs. E.g. main, master etc" + default: "main" set-environment-variables-for-job: - description: 'Applies the derived SHAs for base and head as NX_BASE and NX_HEAD environment variables within the current Job' - default: 'true' - error-on-no-matching-tags: - description: 'By default, if no matching tags are found on the main branch to determine the SHA, we will log a warning and use HEAD~1. Enable this option to error and exit instead.' + description: "Applies the derived SHAs for base and head as NX_BASE and NX_HEAD environment variables within the current Job" + default: "true" + error-on-no-successful-workflow: + description: "By default, if no successful workflow is found on the main branch to determine the SHA, we will log a warning and use HEAD~1. Enable this option to error and exit instead." + workflow-id: + description: "The ID of the workflow to track or name of the file name. E.g. ci.yml. Defaults to current workflow" outputs: base: @@ -23,12 +22,12 @@ outputs: value: ${{ steps.setSHAs.outputs.head }} runs: - using: 'composite' + using: "composite" steps: - name: Set base and head SHAs used for nx affected id: setSHAs shell: bash - run: ${{ github.action_path }}/run.sh '${{ github.event_name }}' '${{ inputs.main-branch-name }}' '${{ inputs.tag-match-pattern }}' '${{ inputs.error-on-no-matching-tags }}' + run: ${{ github.action_path }}/run.sh ${{ github.token }} ${{ github.event_name }} ${{ inputs.main-branch-name }} ${{ inputs.error-on-no-successful-workflow }} ${{ inputs.workflow-id }} - name: Log base and head SHAs used for nx affected shell: bash diff --git a/find-successful-workflow.js b/find-successful-workflow.js new file mode 100644 index 0000000..c3c7d99 --- /dev/null +++ b/find-successful-workflow.js @@ -0,0 +1,69 @@ +const { Octokit } = require("@octokit/action"); +const core = require("@actions/core"); +const { execSync } = require('child_process'); + +const token = process.argv[2]; +const branch = process.argv[3]; +const workflowId = process.argv[4]; +const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); +const run_id = process.env.GITHUB_RUN_ID; +process.env.GITHUB_TOKEN = token; + +(async () => { + try { + const octokit = new Octokit(); + let workflow_id = workflowId; + if (!workflow_id) { + // retrieve workflow-id + workflow_id = await octokit.request(`GET /repos/${owner}/${repo}/actions/runs/${run_id}`, { + owner, + repo, + branch, + run_id + }).then(({ data: { workflow_id } }) => workflow_id); + } + // fetch all workflow runs on a given repo/branch/workflow with push and success + const shas = await octokit.request(`GET /repos/${owner}/${repo}/actions/workflows/${workflow_id}/runs`, { + owner, + repo, + branch, + workflow_id, + event: 'push', + status: 'success' + }).then(({ data: { workflow_runs } }) => workflow_runs.map(run => run.head_sha)); + + const sha = await findExistingCommit(shas); + console.log(sha); + } catch (e) { + core.setFailed(e.message); + process.exit(1); + } +})(); + +/** + * Get first existing commit + * @param {string[]} commit_shas + * @returns {string?} + */ +async function findExistingCommit(shas) { + for (const commitSha of shas) { + if (await commitExists(commitSha)) { + return commitSha; + } + } + return undefined; +} + +/** + * Check if given commit is valid + * @param {string} commitSha + * @returns {boolean} + */ +async function commitExists(commitSha) { + try { + execSync(`git cat-file -e ${commitSha} 2> /dev/null`); + return true; + } catch { + return false; + } +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..17af975 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,166 @@ +{ + "version": "2.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@actions/core": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz", + "integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==" + }, + "@octokit/action": { + "version": "3.10.10", + "resolved": "https://registry.npmjs.org/@octokit/action/-/action-3.10.10.tgz", + "integrity": "sha512-Fga+87chJ0e9V3JRJxkibwtm85nnOA8G+RO5YgG8DJMrFKvSqkGuQy9rHxUhM/5Yu3gVnCOQc/oe5dP/fna/cg==", + "requires": { + "@octokit/auth-action": "^1.2.0", + "@octokit/core": "^3.0.0", + "@octokit/plugin-paginate-rest": "^2.2.4", + "@octokit/plugin-rest-endpoint-methods": "5.4.1", + "@octokit/types": "^6.16.1" + } + }, + "@octokit/auth-action": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-1.3.3.tgz", + "integrity": "sha512-8v4c/pw6HTxsF7pCgJoox/q4KKov4zkgLxEGGqLOZPSZaHf1LqdLlj5m5x5c1bKNn38uQXNvJKEnKX1qJlGeQQ==", + "requires": { + "@octokit/auth-token": "^2.4.0", + "@octokit/types": "^6.0.3" + } + }, + "@octokit/auth-token": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.5.tgz", + "integrity": "sha512-BpGYsPgJt05M7/L/5FoE1PiAbdxXFZkX/3kDYcsvd1v6UhlnE5e96dTDr0ezX/EFwciQxf3cNV0loipsURU+WA==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, + "@octokit/core": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.5.1.tgz", + "integrity": "sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==", + "requires": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.6.0", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.12", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", + "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", + "requires": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/graphql": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.6.4.tgz", + "integrity": "sha512-SWTdXsVheRmlotWNjKzPOb6Js6tjSqA2a8z9+glDJng0Aqjzti8MEWOtuT8ZSu6wHnci7LZNuarE87+WJBG4vg==", + "requires": { + "@octokit/request": "^5.6.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/openapi-types": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-8.3.0.tgz", + "integrity": "sha512-ZFyQ30tNpoATI7o+Z9MWFUzUgWisB8yduhcky7S4UYsRijgIGSnwUKzPBDGzf/Xkx1DuvUtqzvmuFlDSqPJqmQ==" + }, + "@octokit/plugin-paginate-rest": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.14.0.tgz", + "integrity": "sha512-S2uEu2uHeI7Vf+Lvj8tv3O5/5TCAa8GHS0dUQN7gdM7vKA6ZHAbR6HkAVm5yMb1mbedLEbxOuQ+Fa0SQ7tCDLA==", + "requires": { + "@octokit/types": "^6.18.0" + } + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.4.1.tgz", + "integrity": "sha512-Nx0g7I5ayAYghsLJP4Q1Ch2W9jYYM0FlWWWZocUro8rNxVwuZXGfFd7Rcqi9XDWepSXjg1WByiNJnZza2hIOvQ==", + "requires": { + "@octokit/types": "^6.18.1", + "deprecation": "^2.3.1" + } + }, + "@octokit/request": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.0.tgz", + "integrity": "sha512-4cPp/N+NqmaGQwbh3vUsYqokQIzt7VjsgTYVXiwpUP2pxd5YiZB2XuTedbb0SPtv9XS7nzAKjAuQxmY8/aZkiA==", + "requires": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.1.0", + "@octokit/types": "^6.16.1", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.1", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/request-error": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", + "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", + "requires": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "@octokit/types": { + "version": "6.19.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.19.0.tgz", + "integrity": "sha512-9wdZFiJfonDyU6DjIgDHxAIn92vdSUBOwAXbO2F9rOFt6DJwuAkyGLu1CvdJPphCbPBoV9iSDMX7y4fu0v6AtA==", + "requires": { + "@octokit/openapi-types": "^8.3.0" + } + }, + "before-after-hook": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz", + "integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==" + }, + "deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/package.json b/package.json index 67c27ca..477841f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,9 @@ { "private": true, - "version": "1.0.1", - "description": "This package.json is here purely to control the version of the Action, in combination with https://github.com/JamesHenry/publish-shell-action" + "version": "2.0.0", + "description": "This package.json is here purely to control the version of the Action, in combination with https://github.com/JamesHenry/publish-shell-action", + "dependencies": { + "@actions/core": "^1.4.0", + "@octokit/action": "^3.10.10" + } } diff --git a/run.sh b/run.sh index cac1f63..e75376b 100755 --- a/run.sh +++ b/run.sh @@ -1,52 +1,51 @@ #!/bin/bash # We are the only consumers of this script (within action.yml), so no great need for input validation here -GITHUB_EVENT_NAME=$1 -INPUTS_MAIN_BRANCH_NAME=$2 -INPUTS_TAG_MATCH_PATTERN=$3 -INPUTS_ERROR_ON_NO_MATCHING_TAGS=$4 +GITHUB_TOKEN=$1 +GITHUB_EVENT_NAME=$2 +INPUTS_MAIN_BRANCH_NAME=$3 +INPUTS_ERROR_ON_NO_SUCCESSFUL_WORKFLOW=$4 +INPUTS_WORKFLOW_ID=$5 if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then BASE_SHA=$(echo $(git merge-base origin/$INPUTS_MAIN_BRANCH_NAME HEAD)) else # For the base SHA for main builds we use the latest matching tag as a marker for the last commit which was successfully built. # We use 2> /dev/null to swallow any direct errors from the command itself so we can provide more useful messaging - TAG=$(git describe --tags --abbrev=0 --match="$INPUTS_TAG_MATCH_PATTERN" 2> /dev/null) + BASE_SHA=$(node find-successful-workflow.js $GITHUB_TOKEN $INPUTS_MAIN_BRANCH_NAME $INPUTS_WORKFLOW_ID) - if [ -z $TAG ]; then - if [ $INPUTS_ERROR_ON_NO_MATCHING_TAGS = "true" ]; then + if [ -z $BASE_SHA ]; then + if [ $INPUTS_ERROR_ON_NO_SUCCESSFUL_WORKFLOW = "true" ]; then echo "" - echo "ERROR: Unable to resolve a latest matching tag on 'origin/$INPUTS_MAIN_BRANCH_NAME' based on the pattern '$INPUTS_TAG_MATCH_PATTERN'" + echo "ERROR: Unable to find a successful workflow run on 'origin/$INPUTS_MAIN_BRANCH_NAME'" echo "" - echo "NOTE: You have set 'error-on-no-matching-tags' on the action so this is a hard error." + echo "NOTE: You have set 'error-on-no-successful-workflow' on the action so this is a hard error." echo "" - echo "Is it possible that you have no relevant tags currently on 'origin/$INPUTS_MAIN_BRANCH_NAME' in your repo?" + echo "Is it possible that you have no runs currently on 'origin/$INPUTS_MAIN_BRANCH_NAME' in your repo?" echo "" - echo "- If yes, then you simply need to manually apply a tag which matches the 'tag-match-pattern' of '$INPUTS_TAG_MATCH_PATTERN'." - echo "- If no, then you likely have an issue with the pattern above as it is not matching the tag you are expecting it to." + echo "- If yes, then you should run the workflow without this flag first." + echo "- If no, then you might have changed your git history and those commits no longer exist." echo "" exit 1 else echo "" - echo "WARNING: Unable to resolve a latest matching tag on 'origin/$INPUTS_MAIN_BRANCH_NAME' based on the pattern '$INPUTS_TAG_MATCH_PATTERN'" + echo "WARNING: Unable to find a successful workflow run on 'origin/$INPUTS_MAIN_BRANCH_NAME'" echo "" echo "We are therefore defaulting to use HEAD~1 on 'origin/$INPUTS_MAIN_BRANCH_NAME'" echo "" - echo "NOTE: You can instead make this a hard error by settting 'error-on-no-matching-tags' on the action in your workflow." + echo "NOTE: You can instead make this a hard error by settting 'error-on-no-successful-workflow' on the action in your workflow." echo "" - TAG="HEAD~1" + BASE_SHA=$(echo $(git rev-parse HEAD~1)) fi else echo "" - echo "Successfully found a matching tag on 'origin/$INPUTS_MAIN_BRANCH_NAME' based on the pattern '$INPUTS_TAG_MATCH_PATTERN'" + echo "Found the last successful workflow run on 'origin/$INPUTS_MAIN_BRANCH_NAME'" echo "" - echo "Matching tag: $TAG" + echo "Commit: $BASE_SHA" echo "" fi - - BASE_SHA=$(echo $(git rev-parse $TAG~0)) fi HEAD_SHA=$(git rev-parse HEAD)