name: pipeline on: push: branches: - main tags: - '*' schedule: - cron: "0 22 * * *" # 5 - 7 = [ -2 ] # karena minus, jadi 24 - 2 = [ 22 ] jobs: scheduler_only: name: scheduler_only runs-on: ubuntu-latest steps: - name: Set global directory run: git config --global --add safe.directory /github/workspace - uses: actions/checkout@v3 with: lfs: true persist-credentials: false fetch-depth: 1 - name: Read pipeline schedule date id: read_schedule run: | SCHEDULE_DATE=$(cat pipeline_schedule.ctl) echo "schedule_date=${SCHEDULE_DATE}" >> $GITHUB_ENV - name: Get current date id: get_date run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Check if dates match id: date_check run: | if [ "$schedule_date" = "$current_date" ]; then echo "match=true" >> $GITHUB_ENV else echo "match=false" >> $GITHUB_ENV fi - name: Set Pipeline Schedule if: env.match != 'true' run: echo "$(date +'%Y-%m-%d')" > pipeline_schedule.ctl - name: Commit changes if: env.match != 'true' run: | git config --local user.email "belajarqywok@gmail.com" git config --local user.name "belajarqywok" git add -A git commit -m "scheduler" - name: Push changes if: env.match != 'true' uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GH_TOKEN }} branch: main web_deployment: name: Web Deployment runs-on: ubuntu-latest needs: scheduler_only environment: Production env: HF_TOKEN: ${{ secrets.HF_TOKEN }} SPACE_NAME: thesis_forecasting_website HF_USERNAME: qywok steps: - name: Set global directory run: git config --global --add safe.directory /github/workspace - uses: actions/checkout@v3 with: persist-credentials: false fetch-depth: 1000 - name: Check git status run: git status - name: Configure git run: | git config --local user.email "alfariqyraihan@gmail.com" git config --local user.name "qywok" - name: Pull changes from remote run: | git pull https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main || \ (git merge --strategy-option theirs) - name: Add and commit changes run: | git add -A git diff-index --quiet HEAD || git commit -m "Web Deployment" - name: Push to Hugging Face run: | git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main --force