Search code examples
githubyamlcontinuous-integrationgithub-actionscontinuous-deployment

Github Actions Workflow fails to set up, unable to resolve action `actions/checkout@3`


My workflow on Github Actions does not run, in fact is fails on set up. The logs are not helpful, and I created a fresh repo to test.

The workflow file passes on yaml-lint and on action-validator.

It installs java and node, builds both apk and aab, uploads apk to a Github Release and aab to Google Play.

Workflow file that fails:

name: Build Android

on:
  release:
    types:
      - published
  workflow_dispatch:
    inputs:
      checkoutRef:
        description: "Tag or SHA ref to checkout"
        required: false
        default: ""

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest

    steps:
      - name: Increase watchers to fix Docker
        run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

      - name: Checkout the repo
        uses: actions/checkout@3
        with:
          persist-credentials: false
          ref: ${{ github.event.inputs.checkoutRef }}

      - name: Set up Java
        uses: actions/setup-java@v3
        with:
          distribution: microsoft
          java-version: 11
          cache: gradle

      - name: Make Gradle executable
        run: chmod +x ./gradlew
        working-directory: ./android

      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version-file: package.json
          cache: yarn

      - name: Install dependencies
        uses: nick-invision/retry@v2
        with:
          timeout_minutes: 5
          max_attempts: 3
          retry_on: error
          command: yarn install --prefer-offline --frozen-lockfile --silent

      - name: Get version
        id: version
        run: echo value=$(node -p "'v'+require('./package.json').version") >> $GITHUB_OUTPUT

      - name: Check if version is prerelease
        id: is-prerelease
        run: echo value=$(node -p "!!require('semver/functions/prerelease')('${{ steps.version.outputs.value }}')") >> $GITHUB_OUTPUT

      - name: Display version and prerelease
        run: |
          echo "Version: ${{ steps.version.outputs.value }}"
          echo "Is Prerelease: ${{ steps.is-prerelease.outputs.value }}"

      - name: Build locales
        run: yarn locale-compile

      - name: Build AAB and APK for staging
        if: "steps.is-prerelease.outputs.value == 'true'"
        run: ./gradlew bundleStagingRelease assembleStagingRelease --no-daemon
        working-directory: ./android

      - name: Build AAB and APK for production
        if: "steps.is-prerelease.outputs.value == 'false'"
        run: ./gradlew bundleProductionRelease assembleProductionRelease --no-daemon
        working-directory: ./android

      - name: Upload APK to Release tagged with current version
        uses: AButler/[email protected]
        with:
          files: ./android/app/build/outputs/apk/**/*.apk
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          release-tag: ${{ steps.version.outputs.value }}

      - name: Upload AAB to Google Play
        uses: r0adkll/upload-google-play@v1
        with:
          packageName: ${{ secrets.ANDROID_PACKAGE_NAME }}
          releaseFiles: ./android/app/build/outputs/bundle/**/*.aab
          serviceAccountJson: ./google-play-service-account.json
          track: ${{ (steps.is-prerelease.outputs.value == 'true' && 'internal') || 'production' }}
          whatsNewDirectory: ./whatsnew

The log from Github:

2023-03-16T14:37:38.8634981Z Requested labels: ubuntu-latest
2023-03-16T14:37:38.8635398Z Job defined at: organization/app/.github/workflows/build-android.yml@refs/tags/v1.0.1-beta.1
2023-03-16T14:37:38.8635435Z Waiting for a runner to pick up this job...
2023-03-16T14:37:39.6458785Z Job is waiting for a hosted runner to come online.
2023-03-16T14:37:42.2986545Z Job is about to start running on the hosted runner: GitHub Actions 3 (hosted)
2023-03-16T14:37:46.3391907Z Current runner version: '2.303.0'
2023-03-16T14:37:46.3421273Z ##[group]Operating System
2023-03-16T14:37:46.3421879Z Ubuntu
2023-03-16T14:37:46.3422372Z 22.04.2
2023-03-16T14:37:46.3422729Z LTS
2023-03-16T14:37:46.3423107Z ##[endgroup]
2023-03-16T14:37:46.3423461Z ##[group]Runner Image
2023-03-16T14:37:46.3423952Z Image: ubuntu-22.04
2023-03-16T14:37:46.3424370Z Version: 20230313.1
2023-03-16T14:37:46.3425002Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20230313.1/images/linux/Ubuntu2204-Readme.md
2023-03-16T14:37:46.3425740Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20230313.1
2023-03-16T14:37:46.3426313Z ##[endgroup]
2023-03-16T14:37:46.3426790Z ##[group]Runner Image Provisioner
2023-03-16T14:37:46.3427215Z 2.0.119.1
2023-03-16T14:37:46.3427530Z ##[endgroup]
2023-03-16T14:37:46.3428755Z ##[group]GITHUB_TOKEN Permissions
2023-03-16T14:37:46.3429599Z Actions: write
2023-03-16T14:37:46.3429975Z Checks: write
2023-03-16T14:37:46.3430573Z Contents: write
2023-03-16T14:37:46.3431071Z Deployments: write
2023-03-16T14:37:46.3431462Z Discussions: write
2023-03-16T14:37:46.3431853Z Issues: write
2023-03-16T14:37:46.3432171Z Metadata: read
2023-03-16T14:37:46.3432583Z Packages: write
2023-03-16T14:37:46.3432954Z Pages: write
2023-03-16T14:37:46.3433344Z PullRequests: write
2023-03-16T14:37:46.3433712Z RepositoryProjects: write
2023-03-16T14:37:46.3434167Z SecurityEvents: write
2023-03-16T14:37:46.3434557Z Statuses: write
2023-03-16T14:37:46.3434977Z ##[endgroup]
2023-03-16T14:37:46.3438440Z Secret source: Actions
2023-03-16T14:37:46.3438940Z Prepare workflow directory
2023-03-16T14:37:46.4281272Z Prepare all required actions
2023-03-16T14:37:46.4458328Z Getting action download info
2023-03-16T14:37:46.8801186Z ##[error]Unable to resolve action `actions/checkout@3`, unable to find version `3`

And this is a similar workflow, for the server repo, that runs successfully:

name: Deploy Release

on:
  release:
    types:
      - published
  workflow_dispatch:
    inputs:
      checkoutRef:
        description: "Tag or SHA ref to checkout"
        required: false
        default: ""

env:
  AWS_SHOULD_DEPLOY_PROD: ${{ secrets.AWS_SHOULD_DEPLOY_PROD }}
  AWS_SHOULD_DEPLOY_STAGING: ${{ secrets.AWS_SHOULD_DEPLOY_STAGING }}

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
      - name: Increase watchers to fix Docker
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

      - name: Checkout the repo
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        uses: actions/checkout@v3
        with:
          persist-credentials: false
          ref: ${{ github.event.inputs.checkoutRef }}

      - name: Set up Node
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        uses: actions/setup-node@v3
        with:
          node-version-file: package.json
          cache: yarn

      - name: Install dependencies
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        uses: nick-invision/retry@v2
        with:
          timeout_minutes: 5
          max_attempts: 3
          retry_on: error
          command: yarn install --prefer-offline --frozen-lockfile --silent

      - name: Get current version
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        id: current-version
        run: echo value=$(node -p "'v'+require('./package.json').version") >> $GITHUB_OUTPUT

      - name: Check if version is prerelease
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' || env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        id: is-prerelease
        run: echo value=$(node -p "!!require('semver/functions/prerelease')('${{ steps.current-version.outputs.value }}')") >> $GITHUB_OUTPUT

      - name: Prepare staging deploy
        if: env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        run: |
          npx aws-multi-env prepare --env "${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_STAGING }}"
          yarn build
          zip -r "$RUNNER_TEMP/deploy-staging.zip" .adminjs .ebextensions .platform dist patches public src temp .npmrc package.json Procfile tsconfig.json tsconfig.build.json yarn.lock
          npx aws-multi-env revert --env "${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_STAGING }}"

      - name: Prepare prod deploy
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' && steps.is-prerelease.outputs.value == 'false'
        run: |
          npx aws-multi-env prepare --env "${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_PROD }}"
          yarn build
          zip -r "$RUNNER_TEMP/deploy-prod.zip" .adminjs .ebextensions .platform dist patches public src temp .npmrc package.json Procfile tsconfig.json tsconfig.build.json yarn.lock
          npx aws-multi-env revert --env "${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_PROD }}"

      - name: AWS deploy on staging
        if: env.AWS_SHOULD_DEPLOY_STAGING == 'true'
        uses: einaregilsson/beanstalk-deploy@v21
        with:
          deployment_package: ${{ runner.temp }}/deploy-staging.zip
          environment_name: ${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_STAGING }}
          application_name: ${{ secrets.AWS_DEPLOY_APPLICATION_NAME }}
          aws_access_key: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }}
          existing_bucket_name: ${{ secrets.AWS_DEPLOY_EXISTING_BUCKET_NAME }}
          region: ${{ secrets.AWS_DEPLOY_REGION }}
          version_description: ${{ github.SHA }}-staging
          version_label: ${{ steps.current-version.outputs.value }}-staging
          wait_for_deployment: false

      - name: AWS deploy on prod
        if: env.AWS_SHOULD_DEPLOY_PROD == 'true' && steps.is-prerelease.outputs.value == 'false'
        uses: einaregilsson/beanstalk-deploy@v21
        with:
          deployment_package: ${{ runner.temp }}/deploy-prod.zip
          environment_name: ${{ secrets.AWS_DEPLOY_ENVIRONMENT_NAME_PROD }}
          application_name: ${{ secrets.AWS_DEPLOY_APPLICATION_NAME }}
          aws_access_key: ${{ secrets.AWS_DEPLOY_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_DEPLOY_SECRET_ACCESS_KEY }}
          existing_bucket_name: ${{ secrets.AWS_DEPLOY_EXISTING_BUCKET_NAME }}
          region: ${{ secrets.AWS_DEPLOY_REGION }}
          version_description: ${{ github.SHA }}
          version_label: ${{ steps.current-version.outputs.value }}
          wait_for_deployment: false

I`ve tried to recreate the repo, lint the workflow file, quote any strings.


Solution

  • Change

      - name: Checkout the repo
        uses: actions/checkout@3
        with:
          persist-credentials: false
          ref: ${{ github.event.inputs.checkoutRef }}
    

    Into

      - name: Checkout the repo
        uses: actions/checkout@v3
        with:
          persist-credentials: false
          ref: ${{ github.event.inputs.checkoutRef }}
    

    Always try to check github action github or marketplace as it says

    unable to find version 3

    even it is not related to the version, that indicates where your issue is at .

    References for your action : https://github.com/marketplace/actions/checkout