Skip to content

Commit

Permalink
add action with python code
Browse files Browse the repository at this point in the history
  • Loading branch information
f-peverali committed Dec 6, 2023
1 parent b6dea2b commit 8f07e59
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .github/workflows/test_action.yaml
name: Test Action
on: [push]

jobs:
get-num-square:
runs-on: ubuntu-latest
name: Returns the number square
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch num squared
id: get_square
uses: ./ # Uses an action in the root directory
# or use a released GitHub Action
# uses: shipyard/github-action/[email protected]
with:
num: 11
- name: Print the square
run: echo "${{ steps.get_square.outputs.num_squared }}"
31 changes: 31 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# action.yaml
name: 'Custom GitHub Action'
description: 'A GitHub Action that takes an input and returns the square of the number'
inputs:
num:
description: 'Enter a number'
required: true
default: "1"
outputs:
num_squared:
description: 'Square of the input'
# need to specify the extra `value` field for `composite` actions
value: ${{ steps.get-square.outputs.num_squared }}
runs:
using: 'composite'
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
run: pip install -r requirements.txt
shell: bash
- name: Pass Inputs to Shell
run: |
echo "INPUT_NUM=${{ inputs.num }}" >> $GITHUB_ENV
shell: bash
- name: Fetch the number's square
id: get-square
run: python src/get_num_square.py
shell: bash

0 comments on commit 8f07e59

Please sign in to comment.