How do I trigger a commit only for a particular user?

When a particular user commits, I want to automatically tag the commit, build and upload it to the release.
How do I write the yml?

You can use if: github.actor == ‘username_you_care_about’

Example workflow here: https://github.com/OWASP/wstg/blob/64631f974d5a4d32731bcd81bb7a6ccf576ce806/.github/workflows/build-pdf.yml#L15

Obviously your steps will be different but it should give you something to model with.

Thank you!
I get it!

It was not working for me.
Because, the particular user is not github user.
Committer is Weblate.
Like this https://github.com/nihongoka/dota2/commit/0c1d7f58d7e09a8c049bdafebb6e9d2c05a0c7da

The github.actor variable refers to the GitHub user but in your case weblate is not a GitHub user. You can find the specifics of the supported variables here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context

There is an action available called rlespinasse/git-commit-data-action which can extract the data you’re interested in and you can then use that to compare against. I’ve attached an example workflow below that will only release when the commit comes from weblate :slight_smile:

name: Release localization data

on: push

jobs:
  # Create a job with the id `restrict` which obtains the committer name
  restrict:
    runs-on: ubuntu-latest
    # A job can expose output to another job
    outputs:
      # The value of `committer` is set (from env.GIT...) _after_ the job is done
      committer: ${{ env.GIT_COMMIT_COMMITTER_NAME }}
    steps:
      - uses: actions/checkout@v2
      # This is the action that sets the value of `env.GIT_COMMIT_COMMITTER_NAME`
      - uses: rlespinasse/git-commit-data-action@v1.x
  release:
    # `needs` creates a dependency between jobs: this job won't run until
    # the `restrict` job is complete
    needs: restrict
    runs-on: ubuntu-latest
    # a job can access the outputs of a job it depends on through `needs`
    if: needs.restrict.outputs.committer == 'weblate'
    steps:
      - name: Get current date
        id: date
        run: TZ=Asia/Tokyo echo "::set-output name=date::$(date +'%Y-%m-%d-%H-%M-%S')"

      - uses: actions/checkout@v2

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
        with:
          tag_name: v${{ steps.date.outputs.date }}
          release_name: v${{ steps.date.outputs.date }}

      - uses: actions/setup-python@v2

      - name: Install packages
        run: pip install vdf vpk

      - name: Build zip file
        run: python scripts/build.py

      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./dota2jp.zip
          asset_name: dota2jp.zip
          asset_content_type: application/zip