GitHub Actions 1 cheatsheet
GitHub Actions 1: Reuse and deploy
4 common GitHub Actions 1 tasks.
Define a reusable workflow
Make a workflow callable from other workflows.
on:
workflow_call:
inputs:
environment:
type: string
required: true
Call a reusable workflow
Run a reusable workflow from a job.
jobs:
deploy:
uses: ./.github/workflows/deploy.yml
with:
environment: staging
secrets: inherit
Build and push a Docker image
Log in to GitHub Container Registry and push an image tagged with the commit SHA.
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
Create a release from a tag
Create a GitHub release with generated notes using the preinstalled gh CLI.
- run: gh release create "$GITHUB_REF_NAME" --generate-notes
env:
GH_TOKEN: ${{ github.token }}