Skip to content

GuillaumeFalourd/useful-actions

Repository files navigation

useful-actions

title

This repository lists some useful generic Actions to use in your Github workflows and repositories.

Summary


πŸ’‘ Good To Know


πŸ”Ž Useful Actions


🌐 Global Actions

Action Cond

Action Cond: GitHub Action to use a if-else operation when needed, to set dynamic configuration of other steps.

Add Label

Add Label: GitHub Action to add GitHub labels to an issue or a pull request.

Add Reviewers

Add Reviewers: Github action that adds Reviewers to the Pull Request.

App Token

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

Assert command line output: Github Action to assert / check a command line output.

Auto Accept Collabs

Auto Accept Collabs: Github Action to accept automatically all collaboration invites. Useful for a bot account.

Auto approve

Auto Approve: Github Action to automatically approve pull requests.

Auto Assign

Auto Assign: Github Action to add reviewers and assignees to a pull request when opened (needs auto_assign.yml configuration file).

Auto Assign Author

Auto Assign Author: Github Action to automatically assigns PR author as an assignee.

Auto merge

Auto Merge: GitHub Action to automatically merge pull requests when they are ready (automerged label).

Branch Names

Branch Names: Github Action to get branch or tag information without the /ref/* prefix.

Cache

Cache: Github Action to cache dependencies and build outputs to improve workflow execution time.

Cancel Workflow

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

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

Checkout: Github Action to checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.

Close Pull Request

Close Pull Request: Github Action to automatically close a pull request (for example if modifying untouchable files).

Commit And Push

Commit And Push: Github Action to commit and push new code to the repository.

Compress Images

Compress Images: Github Action to automatically compresses JPEGs, PNGs and WebPs in Pull Requests.

Copycat

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

Create JSON: GitHub Action to create a .json file dynamically on your workflow.

Create Pull Request

Create Pull Request: GitHub Action to create a pull request for changes to your repository in the actions workspace.

Curl

Curl: GitHub Action to use the curl CLI to perform http requests.

Debug

Debug: GitHub Action to print the environment variables and the event payload. Useful for developing or debugging GitHub Actions.

Delete Artifacts

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

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

Env Vars: GitHub Action to expose useful environment variables.

File Existence

File Existence: Github Action to check if files exists or not.

First Interaction

First Interaction: Github Action to filter pull requests and issues from first-time contributors.

Get Workflow Origin Get Workflow Origin Information

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

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

GHAction Github Status: GitHub Action to check GitHub Status in workflows, allowinf to trigger error if GitHub services are down.

Git Auto Commit

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 Environment Variables: GitHub Action to expose useful environment variables.

Github Script

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

Gitleaks: Github Action to detect hardcoded secrets like passwords, api keys, and tokens in git repos.

GPT Review

GPT Review: Github Action enabling automatic code reviewing in your repository by sending the git diff patches between a head ref and a base ref to OpenAI's API for annotation using Chat GPT (needs OpenAi API Key).

Horusec

Horusec: Github Action to identify vulnerabilities in your project.

Manual Approval

Manual Approval: Github Action to pause a workflow and require manual approval from one or more approvers before continuing.

Paths Filter

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

Pull Request: GitHub Action to create pull requests automatically.

Purge Artifacts

Purge Artifacts: Github Action responsible for deleting old artifacts by setting expire duration.

Read File

Read File: Github Action to read file contents.

Recreate Release

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

Release: GitHub Action for creating GitHub Releases on Linux, Windows, and macOS virtual environments.

Replace Token

Replace Token: GitHub Action for replacing tokens in files.

Replace Values Action: Github Action to replace values in files (secrets or fields).

Repository-Dispatch Repository-Dispatch-Triggered

Repository-Dispatch: GitHub Action to create a repository dispatch event.

Retry Action

Retry Action: GitHub Action to rerun another GitHub Actions and commands.

Set Secrets

Set Secrets: Github Action to Create or edit actions secrets in repository or organizations.

Example

Skip duplicate

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

Stale: GitHub Action to warn and then close issues and PRs that have had no activity for a specified amount of time.

Super Linter

Super Linter: Github Action to help validate your source code.

Upload & Download Artifacts

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

Wait on check: Github Action to pause a workflow until a job in another workflow completes successfully.

Workflow Dispatch Workflow Dispatch Triggered

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

GHAction Container Scan: GitHub Action to check for vulnerabilities in a container image with Trivy.

Hadolint

Hadolint: Github Action to run Hadolint and reports violations given a Dockerfile within a repository on a pull request.

Phonito

Phonito: Github Action to automate scanning Docker images for OS & library vulnerabilities. Need a free Phonito Security account at https://phonito.io.

Publish Docker

Publish Docker: Github Action to build and push containers.

🦾 Other Tools Actions

TODO


🧐 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

Screenshot


🀝 Contribution

Would like to contribute to the repository? Here are the guidelines πŸš€

(Made with contributors-img)