jenkinsgithubterraformaws-cloud9github-actions-runners

github actions - issue in checkout action


I am new to github action runners. I have created a test-master branch from the master and another feature branch also taken out of master test-feature. My test-master branch has a workflow related to terraform. However, I am getting error in the git checkout action PFB the code and error.

name: 'Terraform'
on: [pull_request]

jobs:
  terraform:
    name: 'Terraform'
    runs-on: ubuntu-latest

    # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
    defaults:
      run:
        shell: bash

    steps:
    # Checkout the repository to the GitHub Actions runner
    - name: Checkout
      uses: actions/checkout@test-master

    # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
    - name: Setup Terraform
      uses: hashicorp/setup-terraform@v1
      with:
        cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

    # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
    - name: Terraform Init
      run: terraform init

    # Checks that all Terraform configuration files adhere to a canonical format
    - name: Terraform Format
      id: fmt
      run: terraform fmt --recursive

Whenever I am trying to raise a pull request from the test-feature to test-master It runs the workflow and generates the error. Error: Unable to resolve action actions/checkout@test-master, unable to find version test-master

Kindly guide me why is it not recognizing the test-maser branch.


Solution

  • When you want to use an action, you specify the action name and the version of the action to run. This line:

        - uses: actions/checkout@test-master
    

    indicates that you want to use the actions/checkout action at version test-master. There is no such version of the action.

    You want actions/checkout@v2. If you want to check out your branch called test-master, specify it as an option to the action. For example:

        - name: Checkout
          uses: actions/checkout@v2
          with:
            ref: 'test-master'