How do I specify a specific commit when manually running git action?
Asked Answered
G

2

6

How do I create a workflow that can only be started manually, while it will need to specify a specific commit with which it will work?

Gee answered 21/10, 2022 at 5:10 Comment(0)
M
7

You can manually run a workflow, provided it is configured to run on the workflow_dispatch event.
Add inputs to define your parameter

on:
  workflow_dispatch:
    inputs:
      myCommit:
        description: 'Commit SHA1'
        required: true
        default: 'undefined'
        type: string

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Do something
        run: your_command ${{ inputs.myCommit }}
  ...
Mathre answered 21/10, 2022 at 5:38 Comment(0)
T
6

Here's an example how to check out the specific commit for build:

on:
  workflow_dispatch:
    inputs:
      refToBuild:
        description: 'Branch, tag or commit SHA1 to build'
        required: true
        type: string

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ inputs.refToBuild }}

      - name: Build
        run: <command for build>
Twowheeler answered 31/1, 2023 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.