Basic Actions workflow
XetHub Actions is in early preview with known limitations. Help us improve by filing bugs!
XetHub Actions are customizable YAML workflows that are associated with a XetHub repository. Each workflow is stored as a main.yml
file in a directory named .xethub/workflows
and specifies what code to run when a target event occurs in the repository. The code specified in Actions workflows runs on XetHub-hosted runners and can do anything from printing out statistics to writing reports back to the repository.
Run the basic Hello world! Actions template
-
From your repository, navigate to the
Actions
tab and click on the "Hello world" Action template. -
Take a look at the syntax for triggering a basic printout on any push to the repository:
name: Hello world!
on: push
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Greetings
run: echo "Hello world!" -
Scroll down to click the Commit Changes button, optionally setting a commit message.
-
Committing the Actions YAML file will trigger a run of the Action. Click on the run to see the results.
Customize your first Actions workflow
Once you've tried the template example above, follow these instructions to modify your Action YAML to run a piece of code from your repository.
-
Create a simple
run.sh
in the root of your repository with these simple commands to print out word and character counts for your Actions YAML file:#!/usr/bin/bash
counts=$(wc ".xethub/workflows/main.yml")
countsArray=($counts)
echo main.yml has ${countsArray[1]} words and ${countsArray[2]} characters -
Edit your
.xethub/workflows/main.yml
through the CLI or UI to reflect the following:name: Count my Actions words and characters
on: push # specifies trigger, in this case,
# on any push event to the repository
jobs:
my-job:
runs-on: ubuntu-latest # the Action will run on XetHub servers
# with the ubuntu-latest Docker image
steps:
- name: Checkout code
uses: actions/checkout@v2 # check out repository code
- name: Run a piece of code # run the shell script
run: bash run.sh -
Add and commit the changes to
main.yml
andrun.sh
to your repository, then push your changes:git add .xethub/workflows/main.yml run.sh
git commit -m "Add sample workflow"
git push -
Because the trigger of this Action is on pushes to the repository, the updated Action will automatically run on your push. Navigate to the
Actions
tab of your repository and click on the latest run to see the results: -
You’ve now set up your first code-running XetHub Action!
If your code has dependencies on any packages that are not installed in the ubuntu-latest
image, you will need to install the dependencies yourself as part of your Action. ubuntu-latest
comes with git-xet
, pandas
, and matplotlib
pre-installed.
Manually trigger or view Actions
Navigate to the Actions
tab of your repository through the XetHub UI to trigger a run or see the history of runs.
- To manually trigger a run of the Action defined in
.xethub/workflows/main.yml
, click the Run button in the top right corner. - To see the workflow file that generated the run, click the "View workflow file" button in the top right corner.
- To view the log of a particular Action, click on the Action run row in the table.
What next?
Take this example further and make adjustments to make the Action your own. Continue on to learn how to extend Actions to create automated custom views for your repository.