github-actions

Run Github Actions when pull requests have a specific label

纵饮孤独 提交于 2021-01-02 15:26:57
问题 After reading the documentation of the Events that trigger workflows, I wonder if it's possible to run a workflow with a given label name , like RFR or WIP. I know we can run a workflow when the pull request is labeled, but there is nothing more for a specifc label name : on: pull_request: types: [labeled] Has anyone done this before ? 回答1: You can achieve running a workflow on labeling a Pull Request using a conditional expression like if: ${{ github.event.label.name == 'label_name' }} So if

URL of the last artifact of a GitHub-action build

让人想犯罪 __ 提交于 2021-01-01 04:23:31
问题 I use GitHub-action for my build, and it generates multiple artifacts (with a different name). Is there a way to predict the URL of the artifacts of the last successful build? Without knowing the sha1 , only the name of the artifact and the repo? 回答1: At the moment, no, according to comments from staff although this may change with future versions of the upload-artifact action. After poking around myself, it is possible to get this using the GitHub actions API: https://developer.github.com/v3

How to get branch name on GitHub action?

感情迁移 提交于 2020-12-31 06:20:00
问题 During a GitHub action, I'd like to know the name of the branch: for a push action: name of the current branch for a pull_request action: name of the target branch I need a string like develop , master or feature/xxx (and not refs/pull/…). The ${{ github.ref }} var gives me refs/heads/develop . How can I get only the develop ? 回答1: You can create a step output of the last part of GITHUB_REF like the following. on: push jobs: example: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 -

Get output of a specific step in github actions

Deadly 提交于 2020-12-30 08:46:36
问题 I have this file of GitHub action which runs tests, but now I am integrating slack notification in it. I want to get the output of the Run tests step and send it as a message in the slack step - name: Run tests run: | mix compile --warnings-as-errors mix format --check-formatted mix ecto.create mix ecto.migrate mix test env: MIX_ENV: test PGHOST: localhost PGUSER: postgres - name: Slack Notification uses: rtCamp/action-slack-notify@master env: SLACK_MESSAGE: Run tests output SLACK_TITLE: CI

Getting current branch and commit hash in GitHub action

情到浓时终转凉″ 提交于 2020-12-30 05:46:31
问题 I want to build a docker image using a GitHub action, migrating from TeamCity. In the build script, I want to tag the image with a combination of branch and commit, e.g. master.ad959de . Testing that locally, I get that information like this: git_branch=`git symbolic-ref --short HEAD` git_hash=`git rev-parse --short HEAD` docker_version=${git_branch}.${git_hash} This is the relevant part of the GitHub action: name: CI on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions

Getting current branch and commit hash in GitHub action

早过忘川 提交于 2020-12-30 05:45:37
问题 I want to build a docker image using a GitHub action, migrating from TeamCity. In the build script, I want to tag the image with a combination of branch and commit, e.g. master.ad959de . Testing that locally, I get that information like this: git_branch=`git symbolic-ref --short HEAD` git_hash=`git rev-parse --short HEAD` docker_version=${git_branch}.${git_hash} This is the relevant part of the GitHub action: name: CI on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions

How to connect to Postgres in GithHub Actions

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-29 08:52:11
问题 I am trying GitHub Actions for CI with a Ruby on Rails application. My setup is with VM, not running the Ruby build in a container. This is my workflow yml. It runs all the way without errors until the step "Setup Database". name: Rails CI on: push: branches: - master pull_request: branches: - master jobs: build: runs-on: ubuntu-latest services: postgres: image: postgres:10.10 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: db_test ports: - 5432/tcp options: --health-cmd

How to get the target branch of the GitHub pull request from an Actions?

狂风中的少年 提交于 2020-12-26 07:42:51
问题 When an action is set on pull_request in Github Actions, how to get the target branch? The use case is to retrieve the PR- (and hopefully, branch)-specific commits. 回答1: You can access the target branch with ${{ github.event.pull_request.base.ref }} . To know the full list of properties of the github.event object, try to run more $GITHUB_EVENT_PATH . 回答2: You can see all GitHub actions pull request event properties here. 来源: https://stackoverflow.com/questions/62331829/how-to-get-the-target

How to get the target branch of the GitHub pull request from an Actions?

孤者浪人 提交于 2020-12-26 07:41:26
问题 When an action is set on pull_request in Github Actions, how to get the target branch? The use case is to retrieve the PR- (and hopefully, branch)-specific commits. 回答1: You can access the target branch with ${{ github.event.pull_request.base.ref }} . To know the full list of properties of the github.event object, try to run more $GITHUB_EVENT_PATH . 回答2: You can see all GitHub actions pull request event properties here. 来源: https://stackoverflow.com/questions/62331829/how-to-get-the-target

Share artifacts between workflows / Github Actions

假如想象 提交于 2020-12-26 06:42:39
问题 I know that you can share artifacts between jobs of the same workflow... But how can I share artifacts across different workflows? 回答1: Probably not yet doable: After a workflow ends, you can download an archive of the uploaded artifacts on GitHub by finding the workflow run in the Actions tab. GitHub does not currently offer a REST API to retrieve uploaded artifacts. If you need to access artifacts from a previously run workflow, you'll need to store the artifacts somewhere. For example, you