{"id":15421789,"url":"https://github.com/mxschmitt/actions-cheat-sheet","last_synced_at":"2026-01-26T12:33:40.982Z","repository":{"id":104075278,"uuid":"213718997","full_name":"mxschmitt/actions-cheat-sheet","owner":"mxschmitt","description":"GitHub Actions cheat sheet with some common snippets","archived":false,"fork":false,"pushed_at":"2019-10-08T18:42:39.000Z","size":2,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-01T08:15:54.847Z","etag":null,"topics":["bash","docker","github","github-actions","kubectl","rancher","workflow"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxschmitt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-08T18:21:11.000Z","updated_at":"2023-10-17T04:48:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"8185f4cd-d55d-46ab-9e68-2fa70b0fde7d","html_url":"https://github.com/mxschmitt/actions-cheat-sheet","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"d6a2f4bc5b01cf6a00c78f7f406e412c8412d6bd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Factions-cheat-sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Factions-cheat-sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Factions-cheat-sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Factions-cheat-sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxschmitt","download_url":"https://codeload.github.com/mxschmitt/actions-cheat-sheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239970661,"owners_count":19727010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","docker","github","github-actions","kubectl","rancher","workflow"],"created_at":"2024-10-01T17:35:52.758Z","updated_at":"2026-01-26T12:33:35.963Z","avatar_url":"https://github.com/mxschmitt.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Actions Cheat sheet\n\nThis repository contains often used patterns for automating CI/CD workflows.\n\nKeep in mind, that for most of these patterns the corresponding environment variables or local bash variables are necessary.\n\n## Patterns\n\n### Run a bash script\n\n```yaml\n- name: Deploying XYZ\n  run: bash .github/workflows/deploy.sh\n```\n\n### Exit Bash script on errors\n\n```bash\nset -x\n```\n\n### Login to Docker GitHub Package Registry\n\n```bash\necho \"$DOCKER_PASSWORD\" | docker login docker.pkg.github.com -u \"$DOCKER_USERNAME\" --password-stdin\n```\n\n### Build Docker Image\n\n```bash\nGIT_TAG=\"${GITHUB_REF##refs/tags/}\"\nGIT_BRANCH=\"${GITHUB_REF##refs/heads/}\"\n\nif [[ $GITHUB_REF != $GIT_TAG ]]; then\n    # Use Git Tag as Docker Image Tag, so that it's connected to the corresponding GitHub release\n    DOCKER_IMAGE_TAG=\"$GIT_TAG\"\nelse\n    DOCKER_IMAGE_TAG=\"$(echo $GIT_BRANCH | tr / -)\"\nfi\n\nDOCKER_IMAGE_NAME=\"docker.pkg.github.com/$GITHUB_REPOSITORY/$(basename $GITHUB_REPOSITORY):$DOCKER_IMAGE_TAG\"\n\ndocker build -f deploy/Dockerfile -t $DOCKER_IMAGE_NAME .\n```\n\n### Push Docker Image\n\n```bash\ndocker push $DOCKER_IMAGE_NAME\n```\n\n### Run an Action on some branches and on `tags`\n\n```yaml\nif: |\n    github.event_name == 'create' \u0026\u0026 github.event.ref_type == 'tag' ||\n    (github.event_name == 'push' \u0026\u0026 (\n    endsWith(github.event.ref, '/master') ||\n    endsWith(github.event.ref, '/develop') ||\n    contains(github.event.ref, '/deploy/')\n    ))\n```\n\n### Install `kubectl` and `rancher`\n\n```bash\nsudo curl -sL -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.15.1/bin/linux/amd64/kubectl\nsudo chmod +x /usr/local/bin/kubectl\nsudo curl -sL https://github.com/rancher/cli/releases/download/v2.2.0/rancher-linux-amd64-v2.2.0.tar.gz | sudo tar xvz -C /usr/local/bin/ --strip-components=2\nsudo chmod +x /usr/local/bin/rancher\n```\n\n### Update a Rancher 2 Workload\n\n```bash\nrancher login --context $RANCHER_CONTEXT --token $RANCHER_TOKEN https://rancher.your-company.com/v3\nrancher kubectl set image $RANCHER_RESOURCE $RANCHER_CONTAINER_NAME=$DOCKER_IMAGE_NAME --namespace $RANCHER_NAMESPACE\nrancher kubectl rollout restart $RANCHER_RESOURCE --namespace $RANCHER_NAMESPACE\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxschmitt%2Factions-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxschmitt%2Factions-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxschmitt%2Factions-cheat-sheet/lists"}