diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e5c8fe6..69654f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -81,7 +81,7 @@ jobs: if: github.event_name == 'pull_request' with: commit_message: "[skip ci] Update tests" - file_pattern: ".github/workflows/autogen-test.yaml" + file_pattern: ".github/workflows/test.yaml" branch: ${{ steps.generate_branch.outputs.branch }} create_branch: true @@ -91,7 +91,7 @@ jobs: owner: Y0sh1dk repo: gha-docker-image-exists github_token: ${{ secrets.GHA_TOKEN }} - workflow_file_name: autogen-test.yaml + workflow_file_name: test.yaml ref: ${{ steps.generate_branch.outputs.branch }} wait_workflow: true comment_downstream_url: ${{ github.event.pull_request.comments_url }} diff --git a/.github/workflows/autogen-test.yaml b/.github/workflows/test.yaml similarity index 84% rename from .github/workflows/autogen-test.yaml rename to .github/workflows/test.yaml index 04795ec..b7843f8 100644 --- a/.github/workflows/autogen-test.yaml +++ b/.github/workflows/test.yaml @@ -1,8 +1,6 @@ name: gha-docker-image-exists Test - on: workflow_dispatch: - jobs: success: runs-on: ubuntu-latest @@ -10,10 +8,9 @@ jobs: - name: GHA Docker Image Exists id: gha-docker-image-exists continue-on-error: true - uses: Y0sh1dk/gha-docker-image-exists@feature/ci-testing-action-test + uses: Y0sh1dk/gha-docker-image-exists@main with: image: nginx:latest - - name: Check output run: | if [ ${{ steps.gha-docker-image-exists.outcome == 'success' }} ]; then @@ -21,17 +18,15 @@ jobs: else exit 1 fi - fail: runs-on: ubuntu-latest steps: - name: GHA Docker Image Exists id: gha-docker-image-exists continue-on-error: true - uses: Y0sh1dk/gha-docker-image-exists@feature/ci-testing-action-test + uses: Y0sh1dk/gha-docker-image-exists@main with: image: nginx:invalid-tag - - name: Check output run: | if [ ${{ steps.gha-docker-image-exists.outcome == 'failure' }} ]; then diff --git a/.github/workflows/test.yaml.tmpl b/.github/workflows/test.yaml.tmpl deleted file mode 100644 index 3e8107b..0000000 --- a/.github/workflows/test.yaml.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -name: [[[ .Env.WORKFLOW_NAME ]]] Test - -on: - workflow_dispatch: - -jobs: - success: - runs-on: ubuntu-latest - steps: - - name: [[[ .Env.WORKFLOW_NAME ]]] valid tag - id: gha-docker-image-exists - continue-on-error: true - uses: Y0sh1dk/gha-docker-image-exists@[[[ .Env.ACTION_VERSION ]]] - with: - image: nginx:latest - - - name: Check output - run: | - if [ ${{ steps.gha-docker-image-exists.outcome == 'success' }} ]; then - exit 0 - else - exit 1 - fi - - fail: - runs-on: ubuntu-latest - steps: - - name: [[[ .Env.WORKFLOW_NAME ]]] invalid tag - id: gha-docker-image-exists - continue-on-error: true - uses: Y0sh1dk/gha-docker-image-exists@[[[ .Env.ACTION_VERSION ]]] - with: - image: nginx:invalid-tag - - - name: Check output - run: | - if [ ${{ steps.gha-docker-image-exists.outcome == 'failure' }} ]; then - exit 0 - else - exit 1 - fi diff --git a/Taskfile.yaml b/Taskfile.yaml index e315173..375c170 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -7,6 +7,8 @@ vars: GO_MOD_CACHE_VOLUME: go-module-cache GIT_REPO_NAME: sh: basename $(git rev-parse --show-toplevel) + GIT_REPO_OWNER: Y0sh1dk + GIT_REPO_FULL: "{{ .GIT_REPO_OWNER }}/{{ .GIT_REPO_NAME }}" tasks: create-go-mod-cache-volume: @@ -46,6 +48,20 @@ tasks: hairyhenderson/gomplate:stable \ {{ .COMMAND }} + _yq-docker: &yq-docker + internal: true + cmds: + - | + docker run \ + --rm \ + -e WORKFLOW_NAME={{ .WORKFLOW_NAME }} \ + -e ACTION_VERSION={{ .ACTION_VERSION }} \ + -v $(pwd):/app \ + --user="root" \ + -w /app \ + mikefarah/yq:latest \ + {{ .COMMAND }} + build: <<: *go-docker internal: false @@ -62,20 +78,20 @@ tasks: COMMAND: go build -ldflags="-w -s" -o bin/{{ .GIT_REPO_NAME }}-{{ .GOOS }}-{{ .GOARCH }} *.go {{ .CLI_ARGS }} gen-tests: - <<: *gomplate-docker + <<: *yq-docker internal: false desc: Generate test workflows requires: vars: [ACTION_VERSION] vars: - WORKFLOW_NAME: "{{ .GIT_REPO_NAME }}" - ACTION_VERSION: "{{ .ACTION_VERSION }}" - COMMAND: -f .github/workflows/test.yaml.tmpl --left-delim "[[[" --right-delim "]]]" > .github/workflows/autogen-test.yaml + ACTION_VERSION: "{{ .GIT_REPO_FULL}}@{{ .ACTION_VERSION }}" + COMMAND: | + -i '.jobs.[].steps[] |= (select(has("uses") and .uses == "{{ .GIT_REPO_FULL }}@*") | .uses = env(ACTION_VERSION))' .github/workflows/test.yaml build-all: desc: Build the application for all platforms vars: - ALL_OS: linux darwin windows + ALL_OS: linux darwin ALL_ARCH: amd64 arm64 cmds: - | diff --git a/bin/gha-docker-image-exists-darwin-amd64 b/bin/gha-docker-image-exists-darwin-amd64 index 9a30502..b1cdb3d 100755 Binary files a/bin/gha-docker-image-exists-darwin-amd64 and b/bin/gha-docker-image-exists-darwin-amd64 differ diff --git a/shim.js b/shim.js index 2f01d61..70c1cb1 100644 --- a/shim.js +++ b/shim.js @@ -12,12 +12,12 @@ function chooseBinary() { if (platform === 'linux' && arch === 'arm64') { return `gha-docker-image-exists-linux-arm64` } - if (platform === 'windows' && arch === 'x64') { - return `gha-docker-image-exists-windows-amd64` - } - if (platform === 'windows' && arch === 'arm64') { - return `gha-docker-image-exists-windows-arm64` - } + // if (platform === 'win32' && arch === 'x64') { + // return `gha-docker-image-exists-windows-amd64` + // } + // if (platform === 'win32' && arch === 'arm64') { + // return `gha-docker-image-exists-windows-arm64` + // } if (platform === 'darwin' && arch === 'x64') { return `gha-docker-image-exists-darwin-amd64` }