DEV Community

Freddy Adiv
Freddy Adiv

Posted on

Workflows with github

Adding actions on GitHub allows you to automate various tasks and workflows within your repositories. Actions are event-driven scripts that run in response to specific triggers. Here's a guide on how to add actions on GitHub:

Access the Repository

  1. Log in to your GitHub account and navigate to the main page.
  2. Select the repository where you want to add actions. If the repository doesn't exist, create a new one by clicking on the "New" button, or clone an existing repository from another user.

Create the Actions Workflow File
The easiest way to configure actions is to use the github Actions button in the repository, but in this post I will cover how to add it manually.

  1. Inside the repository (bash), navigate to the root directory or the .git folder.
  2. If the .git folder doesn't exist, create it.
  3. Inside the .git folder, create a new folder named workflows.
  4. In this folder, create a new YAML file with a descriptive name, such as actions.yml.

Define the Workflow

  1. Open the YAML file you created and define the structure of your workflow.
  2. Start by specifying the name and on fields. The name field is a descriptive name for your workflow, while the on field defines the trigger event that will initiate the workflow. For example, you can set it to push to trigger the workflow whenever code is pushed to the repository.
  3. Add the necessary jobs to your workflow. Jobs are the individual units of work that your workflow will perform. Specify a name for each job and define the steps it needs to execute.

Configure Actions

  1. Within each job, you can configure actions to perform specific tasks.
  2. Actions are pre-built or custom scripts that are executed within your workflow.
  3. You can choose from a wide range of pre-built actions available in the GitHub Marketplace by searching for specific functionality.
  4. If you have a custom script, you can create an action within your repository by defining the necessary steps.

Commit and Push

  1. After defining your workflow and configuring the necessary actions, save the YAML file.
  2. Commit the file to your repository by staging and adding a commit message.
  3. Push the commit to the repository.

Test the Workflow

  1. Once you push the commit, GitHub will automatically start processing the workflow defined in your YAML file.
  2. You can observe the progress and logs of your workflow by navigating to the "Actions" tab in your repository.
  3. GitHub will display the status of each job and the output generated by the actions.

As an example, I added a Workflow for penn cloned to my user.
In this workflow, I added an automatic installation of all requirements and run the test whenever the user pushes or PR the repository.

Thanks Gabor for providing sample CIs in the course.
Cheers and happy workflowing :-)

Top comments (0)