diff --git a/.github/workflows/cd-module.yml b/.github/workflows/cd-module.yml index e7697b6..541db4d 100644 --- a/.github/workflows/cd-module.yml +++ b/.github/workflows/cd-module.yml @@ -15,6 +15,12 @@ on: description: Value `true` will skip version checks, use for testing or in nightly builds. type: boolean required: false + ref_name: + type: string + description: Git branch or tag name to checkout. + default: ${{ github.ref_name }} + required: false + jobs: setup: runs-on: ubuntu-latest @@ -23,8 +29,11 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ inputs.ref_name }} fetch-depth: "0" - + - name: Get checked out SHA + id: checked_out_sha + run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Test tag name pattern if: ${{ ! inputs.skip_checks }} shell: python @@ -33,7 +42,7 @@ jobs: import sys tag_pattern = r"${{ vars.TAG_REGEX_FOR_DEPLOYMENT }}" - ref = "${{ github.ref_name }}" + ref = "${{ inputs.ref_name }}" if not tag_pattern: sys.exit(0) @@ -45,12 +54,13 @@ jobs: - name: Test branch name pattern if: ${{ ! inputs.skip_checks && vars.BRANCH_REGEX_FOR_DEPLOYMENT != '' }} run: | - git branch --all --list --format "%(refname:lstrip=-1)" --contains "${{ github.ref_name }}" | grep -E "${{ vars.BRANCH_REGEX_FOR_DEPLOYMENT }}" + git branch --all --list --format "%(refname:lstrip=-1)" --contains "${{ inputs.ref_name }}" | grep -E "${{ vars.BRANCH_REGEX_FOR_DEPLOYMENT }}" - name: Setup Matrix id: matrix shell: python env: + CHECKED_OUT_SHA: ${{ steps.checked_out_sha.outputs.sha }} MATRIX: | name: - gnu-12.2.0 @@ -118,7 +128,7 @@ jobs: owner_repo = "${{ github.repository }}" owner, repo = owner_repo.split("/") - ref = "${{ github.sha }}" + ref = os.getenv("CHECKED_OUT_SHA") token = "${{ github.token }}" url = f"https://raw.githubusercontent.com/{owner}/{repo}/{ref}/{input_config_path}" response = requests.get(url, headers={"Authorization": f"token {token}"}) @@ -144,7 +154,7 @@ jobs: strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.matrix) }} - runs-on: [self-hosted, linux, hpc] + runs-on: [self-hosted, linux, hpc-dev] env: GITHUB_TOKEN: ${{ secrets.GH_REPO_READ_TOKEN }} steps: @@ -153,5 +163,5 @@ jobs: github_user: ${{ secrets.BUILD_PACKAGE_HPC_GITHUB_USER }} github_token: ${{ secrets.GH_REPO_READ_TOKEN }} troika_user: ${{ secrets.HPC_CI_SSH_USER }} - repository: ${{ github.repository }}@${{ github.event.pull_request.head.sha || github.sha }} + repository: ${{ github.repository }}@${{ inputs.ref_name }} build_config: ${{ inputs.config_path }}