I would like to get the success/failure output of this action aws-actions/configure-aws-credentials#v1 in my next job. As per the action-output the output is aws-account-id.
hence I created below workflow, doesn't matter what I do, I don't seems to catch the output. My question is how to catch the error/success message for this action.
Right now I'm getting empty even if the job success/failed. Is there any way I can get the output of the steps?
jobs:
deploy_infra:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
output1: ${{ steps.cac.outputs.aws-account-id }}
steps:
- name: Git Checkout
uses: actions/checkout#v3
- name: AWS Role
id: cac
uses: aws-actions/configure-aws-credentials#v1
with:
role-to-assume: arn:aws:iam::${{ github.event.inputs.account_id }}:role/assume-role
aws-region: ${{ github.event.inputs.aws_region }}
mask-aws-account-id: false
alert_job:
if: always()
needs: deploy_infra
name: Testing the status
runs-on: ubuntu-latest
steps:
- run: echo ${{needs.job1.outputs.output1}}
Related
I would like to make it possible to send a message on a specific discord channel via a github action.
I succeeded, but I'm having the problem that I can't wrap the text.
See pictures.
The result I get:
The result I would like to get:
Code:
on:
workflow_dispatch:
inputs:
message:
name: Bot
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: Ilshidur/action-discord#master
with:
args: "${{ github.event.inputs.message }}"
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
Assuming I have two jobs and the second depends on the first one:
jobs:
job-1:
runs-on: ubuntu-latest
steps:
- uses: somerepo/someaction#v1
- uses: anotherrepo/anotheraction#v1
- bash: shell
run: |
do-a-lot-of-stuff
job-2:
runs-on: ununtu-latest
needs: job-1
if: failure()
steps:
- shel: bash
run: echo ${{ needs.job-1.fail.message }}
Is there a way to capture the failure message from job-1?
(from whichever step failed of course)
I have the following two actions, how can I make the second action be executed at the end of the first after making the first one commit and push?
Action1
on:
workflow_dispatch:
inputs:
name: Scrape Data
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run action
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub sets this for you
Action2
on:
workflow_dispatch:
inputs:
name: Visit Data
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run visit
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub sets this for you
You could use the workflow_run trigger on the second workflow.
Example:
name: Visit Data
on:
workflow_run:
workflows: ['Scrape Data'] # First workflow name
types:
- completed # can also use 'requested'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Build
run: npm install
- name: Scrape
run: npm run visit
- uses: mikeal/publish-to-github-action#master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Note that you can't use workflow inputs in that case (I observed you had it set, and if it's necessary you would need to use another trigger, for example through the Github API using a workflow dispatch event with a payload).
I have a Github action workflow which is set to trigger on issue_comment, for example the following
name: Testing actions
on:
issue_comment:
types: [created, edited]
jobs:
testing-actions:
if: github.event.issue.pull_request && contains(github.event.comment.body, '#test')
name: Just testing
runs-on: ubuntu-latest
steps:
- uses: xt0rted/pull-request-comment-branch#v1
id: comment-branch
- uses: actions/checkout#v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Print stuff
run: echo "Hello dudes!"
The workflow is working, it is getting triggered when I comment "#test" on a PR. But I have to check it from the actions tab, the workflow doesn't get associated with any commit or PR, so it doesn't get shown in the checks tab in the PR, or the commits don't show any commit status.
How do I get the workflow status and details in the PR page, so that I don't have to go to actions tab manually to see the results?
I solved this by manually setting the commit status using #myrotvorets/set-commit-status-action. The workflow file ended up being like the following
name: Testing actions
on:
issue_comment:
types: [created, edited]
jobs:
testing-actions:
if: github.event.issue.pull_request && contains(github.event.comment.body, '#test')
name: Just testing
runs-on: ubuntu-latest
steps:
- name: Get PR details
uses: xt0rted/pull-request-comment-branch#v1
id: comment-branch
- name: Set commit status as pending
uses: myrotvorets/set-commit-status-action#master
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
- uses: actions/checkout#v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Print stuff
run: echo "Hello dudes!"
- name: Set final commit status
uses: myrotvorets/set-commit-status-action#master
if: always()
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
This works pretty well, the workflow runs get associated with the PR's head commit, and thus it shows up on the PR page as a check too. Thanks #rethab for the alpha.
My use case is, to trigger docs build when there is a trigger word in Pull Request Comments.
I am using pull-request-comment-trigger to know if a Trigger word is present in the code.
After knowing Action is triggered, I want to run some commands inside the repo. So, I have to use actions/checkout for that.
My doubt is, inside the run command, Only Shell Commands are valid, Right? I want to run another job if above condition satisfies.
My Current Yaml File
name: Testing GH Actions
on:
pull_request:
types: [opened]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: khan/pull-request-comment-trigger#master
id: check
with:
trigger: "AppajiC"
reaction: rocket
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- run:
# Generally Anything here runs if below condition satisfies.
# I want to run another job here, which uses actions/checkout#v2 action
if: steps.check.outputs.triggered == 'true'
How can I achieve this ?
You can use the condition for your checkout step and the following steps:
- name: Checkout
uses: actions/checkout#v2
if: steps.check.outputs.triggered == 'true'
- name: Following step1
if: steps.check.outputs.triggered == 'true'
...
Alternatively, you can create a new job and use that if condition once:
jobs:
deploy:
runs-on: ubuntu-latest
outputs:
deploy-status: ${{ steps.check.outputs.triggered }}
steps:
- uses: khan/pull-request-comment-trigger#master
id: check
with:
trigger: 'AppajiC'
reaction: rocket
env:
GITHUB_TOKEN: ${{ github.token }}
# this job will only run if steps.check.outputs.triggered == 'true'
# you just need to write the if once
after-deploy:
runs-on: ubuntu-latest
needs: [deploy]
if: needs.deploy.outputs.deploy-status == 'true'
steps:
- name: Checkout
uses: actions/checkout#v2
...