Skip to content

Commit

Permalink
Attempt to gen and trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Y0sh1dk committed Dec 11, 2023
1 parent 3abfaad commit 37d7dcb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
commit_message: Update compiled binaries
file_pattern: "bin/*"

test-gen:
gen-tests:
needs: [lint, build]
runs-on: ubuntu-latest
permissions:
Expand All @@ -55,13 +55,31 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- uses: jason-dour/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: gomplate --version
- name: Install Task
uses: arduino/setup-task@v1

- name: Check SHA
- name: Generate tests
run: |
echo "${{ github.event.pull_request.head.sha }}"
echo "${{ github.ref }}"
task gen-tests
- uses: stefanzweifel/git-auto-commit-action@v5
if: github.event_name == 'pull_request'
with:
commit_message: Update tests
file_pattern: ".github/workflows/test.yaml"

trigger-tests:
needs: [gen-tests]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Trigger generated tests
uses: convictional/[email protected]
with:
owner: Y0sh1dk
repo: gha-docker-image-exists
github_token: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
workflow_file_name: test.yml
ref: ${{ github.head_ref}}
wait_workflow: true
12 changes: 4 additions & 8 deletions .github/workflows/test.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: {{{ .Env.ACTION_NAME }}}
name: [[[ .Env.WORKFLOW_NAME ]]] Test

on:
workflow_dispatch:
inputs:
version:
description: "Version of action to run"
required: true

jobs:
success:
Expand All @@ -14,7 +10,7 @@ jobs:
- name: GHA Docker Image Exists
id: gha-docker-image-exists
continue-on-error: true
uses: Y0sh1dk/gha-docker-image-exists@{{{ .Env.ACTION_VERSION }}}
uses: Y0sh1dk/gha-docker-image-exists@[[[ .Env.ACTION_VERSION ]]]
with:
image: nginx:latest

Expand All @@ -32,9 +28,9 @@ jobs:
- name: GHA Docker Image Exists
id: gha-docker-image-exists
continue-on-error: true
uses: Y0sh1dk/gha-docker-image-exists@{{{ .Env.ACTION_VERSION }}}
uses: Y0sh1dk/gha-docker-image-exists@[[[ .Env.ACTION_VERSION ]]]
with:
image: nginx:foobar
image: nginx:invalid-tag

- name: Check output
run: |
Expand Down
22 changes: 22 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ tasks:
golang:{{ .GO_VERSION }} \
{{ .COMMAND }}
_gomplate-docker: &gomplate-docker
internal: true
cmds:
- |
docker run \
--rm \
-e WORKFLOW_NAME={{ .WORKFLOW_NAME }} \
-e ACTION_VERSION={{ .ACTION_VERSION }} \
-v $(pwd):/app \
-w /app \
hairyhenderson/gomplate:stable \
{{ .COMMAND }}
build:
<<: *go-docker
internal: false
Expand All @@ -43,6 +56,15 @@ tasks:
vars:
COMMAND: go build -o bin/{{ .GIT_REPO_NAME }}-{{ .GOOS }}-{{ .GOARCH }} *.go {{ .CLI_ARGS }}

gen-tests:
<<: *gomplate-docker
internal: false
desc: Generate test workflows
vars:
WORKFLOW_NAME: "{{ default .GIT_REPO_NAME .WORKFLOW_NAME }}"
ACTION_VERSION: "{{ .ACTION_VERSION }}"
COMMAND: -f .github/workflows/test.yaml.tmpl --left-delim "[[[" --right-delim "]]]" > .github/workflows/test.yaml

build-all:
desc: Build the application for all platforms
vars:
Expand Down

0 comments on commit 37d7dcb

Please sign in to comment.