어떻게 만들 수 있습니 작업에 github 작업 실행하이 무작위로 1~50 회?

0

질문

어떻게 만들 수 있습니 작업에 github 작업 실행하이 무작위로 1~50 회?

여기에 내 cron 작업입니다.

cron:'0 0 * * *'

이 하루에 한 번 실행됩.

하지만 내가 원하는 것은 무작위로 실행 1-50 니다.

나는 어떻게 작동하도록에서 무작위로 1~50?

아래 내 git 작업의 yml 설정 파일 워크플로

#1. Repository Fork
# 2. Modify the files A and B according to the procedure
# 3. After committing the modifications, push & Enjoy!

name: planting-grass

# A. Comment lines 8-11
# on:
# push:
# branches:
# - unknown

# B. Uncomment lines 14-16
on:
   schedule:
     - cron: '0 0 * * *'

jobs:
  task:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set current date
        id: date
        run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
      - name: Execute commands
        run: bash ./task.sh ${{ steps.date.outputs.date }}
      - name: Commit files
        run: |
          git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
          git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
          git add date.txt
          git commit -m ${{ steps.date.outputs.date }}
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

Cron 작업 및 임의의 시간 이내에,주어진 시간 에 방법을 통해 이 게시물 작동하지 않습니다.

enter image description here

Best Regards!

bash cron github-actions sh
2021-11-20 05:36:39
1

최고의 응답

1

당신이 할 수 있는 이것을 수정하여 귀하의 Bash 스크립트 루프의 임의의 숫자의 번입니다. 예를 들어,이 Bash 스크립트 루프 1~50times.

#!/usr/bin/env bash
loops=$(( ( RANDOM % 50 )  + 1 ))
echo "$loops"
for i in $(seq 1 $loops); do
    echo foo
done

하나 이 방법의 단점은 취해야 할 단계에서 수행되는'Commit 파일 단계와 병합으로 스크립트에서 명령을 실행하는 단계,또는 그들은 반복되지 않습니다.

2021-11-20 06:06:40

에 git 작업 환경을 실행할 수 없 yml 환경부에 대한 문의입니다.
emarwa.mouma.35t

진실하다,그러나 모든 것의 당신이 하고 있는 내부의"Commit"파일 단계가 있을 수 있습니다. 구성 Git? 를 수행할 수 있습니다. 투입 파일이 있는가? 를 수행할 수 있습니다. 날짜? 를 수행할 수 있습니다.
Nick ODell

의 결과는 이 솔루션: ./task.sh: 4: i: not found
emarwa.mouma.35t

@emarwa.mouma.35t 당신이 진정으로 걱정하지 않은 간격으로,이 접근법은 최고의 IMO. 일단 하루에,스크립트/코드 실행 1~50 습니다. 당신은 그것을 구현할 수 있습니다 래퍼로 호출하는 스크립트 ./task.sh (신 echo foo다),또는,추가 루프를 task.sh. 내가 사용하는 것 for ((i=1; i<=loops; i++))seq지만,그것은 중요하지 않습니다.
dan

@emarwa.mouma.35t 처럼에 오류가 이전 문제,그리고 내 응답을 지정해야 합니다. 실행 while (( i <= loops )) (또는 유사한)에 sh 을 생산하는 오류가 있습니다.
dan

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................