Skip to content

Commit

Permalink
chore(gh-action): 👷 (#388) use workflow calls instead of tag trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasAugustin committed Sep 24, 2023
1 parent f362753 commit 7466fcb
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 62 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Lint

on:
pull_request:
push:
# manual trigger
branches:
- "!main"
pull_request:
workflow_call:
workflow_dispatch:

jobs:

lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: markdownlint
run: make markdownlint
- name: prune
run: make prune
- uses: actions/checkout@v3
- name: markdownlint
run: make markdownlint
- name: prune
run: make prune
36 changes: 10 additions & 26 deletions .github/workflows/push_docker.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,59 @@
name: push-docker

on:
# Allow manual runs.
workflow_dispatch:
# Also run on updates to this repo.
push:
branches:
- main
tags:
- 'v*'
paths-ignore:
- '**/*.md'
workflow_call:

jobs:

build-and-push:
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
matrix:
variant: [ "actions-template-sync" ]
variant: ["actions-template-sync"]

steps:
-
name: checkout
- name: checkout
uses: actions/checkout@v3
-
name: Login to DockerHub
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Extract metadata (tags, labels) for Docker
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
andyAugustin/${{ matrix.variant }}
ghcr.io/AndreasAugustin/${{ matrix.variant }}
-
name: Build and push ${{ matrix.variant }}
- name: Build and push ${{ matrix.variant }}
uses: docker/build-push-action@v3
with:
context: ./src/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Docker Hub Description
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: andyAugustin/${{ matrix.variant }}
# readme-filepath: ./images/${{ matrix.variant }}/README.md
# short-description: See https://github.com/${{ github.repository }}/images/${{ matrix.variant }} for the source.
-
name: run tests
- name: run tests
run: |
echo "Install container tools"
curl -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 \
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
push:
branches:
- main

jobs:
call_shellcheck:
uses: ./.github/workflows/shellcheck.yml
call_lint:
uses: ./.github/workflows/lint.yml
call_test_all:
uses: ./.github/workflows/test_all.yml
call_release_please:
needs:
- call_shellcheck
- call_lint
- call_test_all
permissions:
contents: write
pull-requests: write
uses: ./.github/workflows/release_please.yml
call_push_docker:
if: ${{ needs.call_release_please.outputs.release_created }}
needs:
- call_release_please
permissions:
contents: read
packages: write
uses: ./.github/workflows/push_docker.yml
secrets: inherit
11 changes: 8 additions & 3 deletions .github/workflows/release_please.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: release-please

on:
push:
branches:
- main
workflow_call:
outputs:
release_created:
description: "Set if the release has been created"
value: ${{ jobs.release-please.outputs.release_created }}
tag_name:
description: "The tag name"
value: ${{ jobs.release-please.outputs.tag_name }}
workflow_dispatch:

permissions:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ name: shellcheck

on:
push:
branches:
- "!main"
pull_request:
workflow_call:
workflow_dispatch:

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run shellcheck in container
run: make shellcheck
- uses: actions/checkout@v3
- name: Run shellcheck in container
run: make shellcheck
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: test

on:
pull_request:
push:
# manual trigger
workflow_dispatch:
branches:
- "!main"
pull_request:
workflow_call:

jobs:
test-implementation-job:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/test_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test-all

on:
push:
branches:
- "!main"
# pull_request:
workflow_call:
workflow_dispatch:

jobs:
call_test_hooks:
uses: ./.github/workflow/test_hooks.yml
call_test_ssh_gitlab:
uses: ./.github/workflows/test_ssh_gitlab.yml
call_test_ssh:
uses: ./.github/workflows/test_ssh.yml
call_test:
uses: ./.github/workflows/test.yml
14 changes: 6 additions & 8 deletions .github/workflows/test_hooks.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
name: test-hooks

on:
pull_request:
push:
# manual trigger
# branches:
# - "!main"
# pull_request:
workflow_call:
workflow_dispatch:

jobs:

test-implementation-job:

runs-on: ubuntu-latest

steps:
# To use this repository's private action, you must check out the repository
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Test action step
- name: Test action step
uses: ./ # Uses an action in the root directory
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test_ssh.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: test-ssh

on:
# pull_request:
push:
# manual trigger
workflow_dispatch:
branches:
- "!main"
pull_request:
workflow_call:

jobs:
test-implementation-job:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/test_ssh_gitlab.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: test-ssh-gitlab

on:
# pull_request:
push:
# manual trigger
# branches:
# - "!main"
# pull_request:
workflow_call:
workflow_dispatch:

jobs:
test-implementation-job:

runs-on: ubuntu-latest

steps:
# To use this repository's private action, you must check out the repository
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Test action step ssh
- name: Test action step ssh
if: github.repository_owner == 'AndreasAugustin'
uses: ./ # Uses an action in the root directory
with:
Expand Down

0 comments on commit 7466fcb

Please sign in to comment.