useful-actions
This repository lists some useful generic Actions to use in your Github workflows and repositories.
Summary
- Good to Know
- Useful Actions
- How to create new actions
- How to debug workflows
- How to test actions locally
- Contribution
π‘ Good To Know
- Usage Limits
- Workflow syntax for GitHub Actions
- Authentication in a workflow
- Creating a personal access token
π Useful Actions
π Global Actions
Action Cond: GitHub Action to use a if-else
operation when needed, to set dynamic configuration of other steps.
Add Label: GitHub Action to add GitHub labels to an issue or a pull request.
Add Reviewers: Github action that adds Reviewers to the Pull Request.
App Token: Github Action to impersonate a GitHub App when secrets.GITHUB_TOKEN
's limitations are too restrictive and a personal access token is not suitable.
Assert command line output: Github Action to assert / check a command line output.
Auto Accept Collabs: Github Action to accept automatically all collaboration invites. Useful for a bot account.
Auto Approve: Github Action to automatically approve pull requests.
Auto Assign: Github Action to add reviewers and assignees to a pull request when opened (needs auto_assign.yml configuration file).
Auto Assign Author: Github Action to automatically assigns PR author as an assignee.
Auto Merge: GitHub action to automatically merge pull requests when they are ready (automerged
label).
Branch Names: Github Action to get branch or tag information without the /ref/*
prefix.
Cache: Github Action to cache dependencies and build outputs to improve workflow execution time.
Cancel Workflow: Github Action cancel any previous runs that are not completed
for a given workflow. This includes runs with a status of queued
or in_progress
.
Changed Files: Github Action to retrieve all changed files relative to the default branch (pull_request*
based events) or the last remote commit (push
based event) returning the absolute path to all changed files from the project root.
Checkout: Github Action to checks-out your repository under $GITHUB_WORKSPACE
, so your workflow can access it.
Close Pull Request: Github Action to automatically close a pull request (for example if modifying untouchable files).
Commit And Push: Github Action to commit and push new code to the repository.
Compress Images: Github Action to automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Copycat: GitHub action to copy files from your repository to another external repository. It is also possible to copy files from/to repository Wikis.
Create JSON: GitHub Action to create a .json file dynamically on your workflow.
Create Pull Request: GitHub action to create a pull request for changes to your repository in the actions workspace.
Curl: GitHub action to use the curl CLI to perform http requests.
Debug: GitHub action to print the environment variables and the event payload. Useful for developing or debugging GitHub Actions.
Delete Artifacts: GitHub Action to delete artifacts within a workflow run. This can be useful when artifacts are shared across jobs, but are no longer needed when the workflow is complete.
Enforce PR labels: GitHub action to enforce assigning labels before merging PR's. Useful for generating automatic changelog and release notes with github-release-notes
.
Env Vars: GitHub action to expose useful environment variables.
File Existence: Github Action to check if files exists or not.
First Interaction: Github Action to filter pull requests and issues from first-time contributors.
Get Workflow Origin: Github Action to provide information about the pull requests that triggered the workflow for the pull_request
and pull_request_review
events or for the workflow_run
event that is triggered by one of those events.
GHAction Dump Context: GitHub Action to dump context of your workflow (which allows to check all variables available using the github.event
syntax in the workflow).
GHAction Github Status: GitHub Action to check GitHub Status in workflows, allowinf to trigger error if GitHub services are down.
Git Auto Commit: GitHub Action to detect changed files during a Workflow run and to commit and push them back to the GitHub repository. By default, the commit is made in the name of "GitHub Actions" and co-authored by the user that made the last commit.
Github Environment Variables: GitHub Action to expose useful environment variables.
Github Script: Github Action to make it easy to quickly write a script in your workflow that uses the GitHub API and the workflow run context.
Gitleaks: Github Action to detect hardcoded secrets like passwords, api keys, and tokens in git repos.
Horusec: Github Action to identify vulnerabilities in your project.
Manual Approval: Github Action to pause a workflow and require manual approval from one or more approvers before continuing.
Paths Filter: Github Action that enables conditional execution of workflow steps and jobs, based on the files modified by pull request, on a feature branch, or by the recently pushed commits.
Pull Request: GitHub Action to create pull requests automatically.
Purge Artifacts: Github Action responsible for deleting old artifacts by setting expire duration.
Read File: Github Action to read file contents.
Recreate Release: Github Action to delete previous release by tag_name
or release_name
and then call actions/create-release
to create it again.
Release: GitHub Action for creating GitHub Releases on Linux, Windows, and macOS virtual environments.
Replace Token: GitHub Action for replacing tokens in files.
Repository-Dispatch: GitHub Action to create a repository dispatch event.
Retry Action: GitHub Action to rerun another GitHub Actions and commands.
Set Secrets: Github Action to Create or edit actions secrets in repository or organizations.
Skip duplicate: GitHub Action to skip duplicate workflow-runs (after merges, pull requests or similar), skip concurrent or parallel workflow-runs for things that you do not want to run twice, skip ignored paths to speedup documentation-changes or similar, skip if paths not changed for something like directory-specific tests, cancel outdated workflow-runs after branch-pushes.
Stale: GitHub Action to warn and then close issues and PRs that have had no activity for a specified amount of time.
Super Linter: Github Action to help validate your source code.
Upload Artifact: Github Action to share data between jobs and store data once a workflow is complete (example).
Download Artifact: Github Action to download artifacts from your build (example).
Wait on check: Github Action to pause a workflow until a job in another workflow completes successfully.
Workflow Dispatch: Github Action to trigger another GitHub Actions workflow, using the workflow_dispatch
event. The workflow must be configured for this event type e.g. on: [workflow_dispatch]
. This allows you to chain workflows, the classic use case is have a CI build workflow, trigger a CD release/deploy workflow when it completes. Allowing you to maintain separate workflows for CI and CD, and pass data between them as required.
π³ Docker Actions
GHAction Container Scan: GitHub Action to check for vulnerabilities in a container image with Trivy.
Hadolint: Github Action to run Hadolint and reports violations given a Dockerfile within a repository on a pull request.
Phonito: Github Action to automate scanning Docker images for OS & library vulnerabilities. Need a free Phonito Security account at https://phonito.io.
Publish Docker: Github Action to build and push containers.
π§ How to create new actions
The Github tutorial is great to understand how to create:
π΅οΈ How to debug workflows
The action-upterm uses upterm and tmux to offer a direct way to interact with the host system on which the actual actions will run.
By using this minimal example a upterm session will be created.
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup upterm session
uses: lhotari/action-upterm@v1
To get the ssh
connection string, just open the workflow Checks
tab and scroll to the bottom.
Note: If you want to continue a workflow and you are inside a upterm session, just create a empty file with the name continue
either in the root directory or in the workspace directory by running touch continue
or sudo touch /continue
. Closing the terminal will also continue the workflow. However you won't be able to reconnect in that case. It's possible to detach from the terminal and not continue by first pressing C-b and then d (tmux detach command keys).
π€ How to test actions locally
This tool can be used to test actions locally: Act
π€ Contribution
Would like to contribute to the repository? Here are the guidelines
(Made with contributors-img)