简体   繁体   English

GitHub 操作 - 管道

[英]GitHub Actions - PIPELINE

I have to make a part of a pipeline.我必须成为管道的一部分。 On my friends git is already the core of it.我朋友上的git已经是内核了吧。

After every commit, there should be added new things to the file.每次提交后,都应该向文件中添加新内容。 Then this should return file to git. I can see the latest file as one the files in a zip ( as a tag ).然后这应该将文件返回到 git。我可以看到最新的文件是 zip 中的文件之一(作为标签)。

What I want to do?我想做的事? I want to add some code between commit and releasing new file.我想在提交和发布新文件之间添加一些代码。 During that I would like to comment few lines with sed commend in command line ( or any other method), then put it as argument to the robot.jar app (java) and the result return in exactly the same way as before.在此期间,我想在命令行(或任何其他方法)中用 sed commend 评论几行,然后将其作为参数传递给 robot.jar app (java),结果返回的方式与以前完全相同。

I did it locally, but it's hard to put it in github. To be clear: After every new commit, I would like to take file opencs.ttl, make some modification, and then return it as it is now.我在本地做的,但是很难把它放在 github 中。要清楚:每次新提交后,我想获取文件 opencs.ttl,进行一些修改,然后按现在的样子返回。

My code to comment the file locally in command line:我在命令行中本地评论文件的代码:

sed -i '15 s/^/                     foaf:name "XYZ".] #/' <file>
sed -i '16 s/^/#/' <file>
sed -i '21 s/^/#/' <file>

Code to run the robot:运行机器人的代码:

java -jar robot.jar reason --reasoner HermiT --axiom-generators "PropertyAssertion" --input openCS/output_opencs.ttl --output output_opencs2.ttl;

My friends pipeline ( https://github.com/OpenCS-ontology/OpenCS ):我的朋友管道( https://github.com/OpenCS-ontology/OpenCS ):


name: "pre-release"

on:
  push:
    branches:
      - main

jobs:
  pre-release:
    name: "Pre-release"
    runs-on: "ubuntu-latest"
    container: ghcr.io/opencs-ontology/ci-worker:main

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          path: opencs

      - name: "Package ontology"
        run: python /app/package.py opencs package dev

      - uses: "marvinpinto/action-automatic-releases@v1.2.1"
        with:
          repo_token: "${{ secrets.GITHUB_TOKEN }}"
          automatic_release_tag: "dev"
          prerelease: true
          title: "Development build"
          files: package/*


##########################################################
      PROBABLY HERE SHOULD BE MY CODE (?)
##########################################################


      - name: "Prepare ontology files for commit"
        run: |
          mkdir output_files
          gzip -cd package/opencs.ttl.gz > output_files/opencs.ttl
          gzip -cd package/opencs.rdf.gz > output_files/opencs.rdf
          gzip -cd package/opencs.nt.gz > output_files/opencs.nt
      - name: "Push the files to the Github Pages repository"
        uses: "cpina/github-action-push-to-another-repository@main"
        env:
          SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
        with:
          source-directory: 'output_files'
          destination-github-username: 'opencs-ontology'
          destination-repository-name: 'opencs-ontology.github.io'
          user-name: ci-worker
          target-directory: /releases/latest
          target-branch: main

I did it locally and I can convert it using my code, then I can input it to the robot.jar and 'reason' it.我在本地完成,我可以使用我的代码转换它,然后我可以将它输入到 robot.jar 并“推理”它。 Now I have no idea how to do the same things with git actions.现在我不知道如何用 git 动作做同样的事情。

First of all, Github does not always know when you commit stuff.首先,Github 并不总是知道你什么时候提交东西。 But Github can only run Actions when it knows about an event, and that is a change in their hosted repository.但是 Github 只能在知道事件时运行 Actions,这是他们托管的存储库中的更改。 That means either you commit via the web interface directly on Github, or you commit in your local git client and push the changes to Github.这意味着您要么直接在 Github 上通过 web 接口提交,要么在本地 git 客户端提交并将更改推送到 Github。

Very likely you should add your code after the Checkout repository step and before python creates the package in the Package ontology step.您很可能应该在Checkout repository步骤之后和 python 在Package ontology步骤中创建 package 之前添加您的代码。

Use run steps to execute your sed and java commands.使用run步骤执行 sed 和 java 命令。 https://docs.github.com/en/actions/learn-github-actions/essential-features-of-github-actions#adding-scripts-to-your-workflow https://docs.github.com/en/actions/learn-github-actions/essential-features-of-github-actions#adding-scripts-to-your-workflow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM