I am trying to setup the GitHub actions for deployment to the Azure. What I am trying to do is getting the name of some variables from the armtemplates with the given code.
name: Create Initial Resources
on:
push:
branches:
- CreateResources
jobs:
Read:
runs-on: ubuntu-latest
steps:
- name: Chekout branch
uses: actions/checkout#v2
with:
ref: CreateResources
- name: get storage account
run: |
echo ::set-output name=storage-account-name::$(jq '.parameters.storage_account_name.value' at ./armtemplates/sac/parameters-example.json)
This is the code that I use, first it checks the branch and in the second step it tries to parse the file that is in the branch but the error is like this:
jq: error: Could not open file at: No such file or directory
Issue here is at phrase. Please use this:
echo ::set-output name=storage-account-name::$(jq '.parameters.storage_account_name.value' ./armtemplates/sac/parameters-example.json)
Related
on: pull_request
jobs:
job1:
runs-on: [re-centos7]
# Map a step output to a job output
outputs:
output1: ${{ steps.step1.outputs.test }}
output2: ${{ steps.step2.outputs.test }}
steps:
- id: step1
run: echo "test=world1" >> $env:GITHUB_OUTPUT
- id: step2
run: echo "test=world" >> $env:GITHUB_OUTPUT
job2:
runs-on: [re-centos7]
needs: job1
steps:
- run: echo ${{needs.job1.outputs.output1}}
output
I'm trying to use the job's output in the next job. I'm trying to use github output for this but I see it's getting an empty value for the output. Can someone help? Thanks!
output is empty for ${{needs.job1.outputs.output1}}
I'm using self-hosted runners which are integrated with Kubernetes cluster
The first thing to check is the version of your self-hosted runners: The deprecation of set-output was mentioned recently (oct. 2022)
If you are using self-hosted runners make sure they are updated to version 2.297.0 or greater.
If the version is lower, that would explain the empty values.
I've already attempted to ask about this on the repo itself with no luck so far.
I've created a fairly simple workflow based on this SO answer to retrieve a forgotten secret:
name: Show Me the S3cr3tz
on: [push]
jobs:
debug:
name: Debug
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout#v2
- name: Set up secret file
env:
MY_SECRET: ${{ secrets.MY_SECRET }}
run: |
echo $MY_SECRET >> secrets.txt
- name: Run tmate
uses: mxschmitt/action-tmate#v3
However, I can never see the tmate link because it is cancelled automatically and immediately after leaving the queue:
What am I doing wrong?
This is probably related to the recent GitHub Actions outage.
The workflow YAML syntax is valid, and confirmed to be working.
I am trying to get a private GitHub action to work within my private GitHub org. The private repo that contains these workflow 'templates' has this simple file structure as I'm just trying to get the bare minimum to work:
.
├── .git
├── test
│ ├── action.yml
And the action.yml file contents are:
name: Test
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Echo
run: |
echo Heyyyyy
I am trying to use this action in another private repo with a workflow file with these contents:
name: Test
on:
push:
branches:
- master
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
repository: <private-actions-repo>
token: ${{ secrets.REPO_TOKEN }}
path: github-actions
- name: Test private action
uses: ./github-actions/test
When this action runs, I get the following error:
##[error]Top level 'runs:' section is required for /home/runner/work/<private-repo>/./github-actions/test/action.yaml
Trying to debug this, I updated the workflow that uses the template to cat the file contents of this file:
- name: Test private action
run: |
cat ./github-actions/test/action.yml
..and I get the contents I would expect:
> Run cat ./github-actions/test/action.yml
name: Test
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Echo
run: |
echo Heyyyyy
Why would this not be working when using it from the action repo, but the exact same content works in the target repo?
You have to differentiate between workflows, actions, and different action types.
Workflows are toplevel elements and not composable. Actions are building blocks that can be used in workflows. The action you defined in action.yml is actually a workflow but should be a composite run steps action, i.e. a specific type of action, that has to follow the rules given in:
https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions
You can find an example for a composite run steps action here:
https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action#creating-an-action-metadata-file
If you use the following as action.yaml, it should work:
name: Test
description: 'composite run action'
runs:
using: "composite"
steps:
steps:
- name: Echo
shell: bash
run: |
echo Heyyyyy
Is there a way to get and set the Github’s pull request number (example PR #323 ) into Github Actions’s Environment Variable (without the hashtag)?
env:
GITHUB_PR_NUMBER: 323
on:
pull_request
env:
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
jobs:
prJob:
name: Print event
runs-on: ubuntu-latest
steps:
- run: |
echo "$GITHUB_PR_NUMBER"
For more information, see https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
Howdo i create a random uuid from a github action? I found a third party github action that creates a random uuid but i am hoping there is some native action that already supports this scenario.
as an improvement to the answer from #riQQ
name: Test linux job
on:
push
jobs:
testJob:
name: Test
runs-on: ubuntu-latest
steps:
- name: Get uuid
id: uuid
run: |
echo "::set-output name=uuid::$(uuidgen)"
With a Linux runner you can use uuidgen:
name: Test linux job
on:
push
jobs:
testJob:
name: Test
runs-on: ubuntu-latest
steps:
- run: |
uuidgen
This will output the uuid to the console. You can then redirect the output to a file or a variable with the standard shell mechanisms.