GitHub Actions คือเครื่องมือในการทำ CI/CD ที่ช่วยให้คุณสร้าง ทดสอบ และไปป์ไลน์การปรับใช้โดยอัตโนมัติ คุณสามารถสร้างเวิร์กโฟลว์ที่สร้างและทดสอบทุกคำขอดึงไปยังที่เก็บของคุณได้อย่างง่ายดาย
ถ้าอยากอ่านฉบับเต็มตามไปอ่านได้ที่นี่ https://www.khomkrit.com/github-actions-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/
ตัวอย่างสคริปที่ใช้งานสำหรับ Github Action โดยสคริปนี้จะทำการรันไฟล์ bot.sh และทำการอัพเดทโค๊ดไปที่ Github ทุก ๆ วัน
# This is a basic workflow to help you get started with Actions
name: bot-create-commit
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '50 1 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Create local changes
run: |
./bot.sh
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
author_email: "tao.isaman@gmail.com"
author_name: "tao-Isaman"
message: "pump commit"