时隔一个月

Wen 发布于 2020-06-14 59 次阅读


发现Github Action能用来定时执行一些任务。
噢,是在妖火看到的
在IBM上的Cloud Foundry弄了个程序,要一直运行,但Cloud Foundry只能运行十天就停止了,所以要有自动程序来自动重启下就好了,妖火老哥就想到利用GitHub Action功能来实现的。
首先创建一个库,公共或者私人,建议私人,因为要用到密码登录,公共会暴露你的密码。
然后点击Action,选择IBM CIL部署
写参数文档,一下是我用到的:

name: IBM Cloud Auto Restart

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
  schedule:
    -  cron: '0 12 * * FRI'

# Environment variables available to all jobs and steps in this workflow
env:
  GITHUB_SHA: {{ github.sha }}
  IBM_CLOUD_API_KEY:{{ secrets.IBM_CLOUD_API_KEY }}
  IBM_CLOUD_REGION: us-south
  ICR_NAMESPACE: ${{ secrets.ICR_NAMESPACE }}
  REGISTRY_HOSTNAME: us.icr.io
  IMAGE_NAME: iks-test
  IKS_CLUSTER: example-iks-cluster-name-or-id
  DEPLOYMENT_NAME: iks-test
  PORT: 5001

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    # Download and Install IBM Cloud CLI
    - name: Install IBM Cloud CLI
      run: curl -sL https://ibm.biz/idt-installer | bash

    # Authenticate with IBM Cloud CLI
    - name: Login IBM Cloud
      run: |
        ibmcloud login <<EOF
        账号
        密码
        7  #地区编号 1.au-syd 2.in-che 3.jp-tok 4.kr-seo 5.eu-de 6.eu-gb 7.us-south 8.us-east 我的是us-south所以是7
        no
        EOF
    - name: Do my jobs
      run: |
        ibmcloud target -g 资源组编号(在IBM的shell里执行ibmcloud resource groups获取)
        ibmcloud target --cf
        ibmcloud cf install
        ibmcloud cf restart 项目名称
此作者没有提供个人介绍
最后更新于 2024-11-08