From 2e59fae695b0ce20934b6e501d3cfc08b8638b1c Mon Sep 17 00:00:00 2001 From: engel80 Date: Sat, 14 Jan 2023 17:19:12 +0900 Subject: [PATCH 1/4] deploy test (#10) --- .github/workflows/dispatch-example.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dispatch-example.yml b/.github/workflows/dispatch-example.yml index df75e8f..3756f3f 100644 --- a/.github/workflows/dispatch-example.yml +++ b/.github/workflows/dispatch-example.yml @@ -12,14 +12,13 @@ on: default: "" description: "Container image registry URL WITHOUT tag e.g., gcr.io/project-id-372417/target-image" -env: - SOURCE_IMAGE_WITH_TAG: ${{ github.env.inputs.source-regurl-tag }} - TARGET_IMAGE_URL: ${{ github.env.inputs.target-regurl }} - jobs: copy_container_image: name: Copy container image runs-on: ubuntu-latest + env: + SOURCE_IMAGE_WITH_TAG: ${{ github.env.inputs.source-regurl-tag }} + TARGET_IMAGE_URL: ${{ github.env.inputs.target-regurl }} steps: - name: Get image tag run: | From 45361411866a201a2bd7c8c37f056f874e10f8a3 Mon Sep 17 00:00:00 2001 From: engel80 Date: Sat, 14 Jan 2023 21:13:49 +0900 Subject: [PATCH 2/4] Dispatch example (#12) --- .github/workflows/dispatch-example.yml | 20 ++++++++++++------- .../workflows/dispatch-request-exmple.json | 4 ++-- README.md | 16 ++++++++------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dispatch-example.yml b/.github/workflows/dispatch-example.yml index 3756f3f..9c99bbd 100644 --- a/.github/workflows/dispatch-example.yml +++ b/.github/workflows/dispatch-example.yml @@ -3,11 +3,11 @@ name: GitHub action dispath on: workflow_dispatch: inputs: - source-regurl-tag: + source_regurl_tag: required: true default: "" description: "Container image registry URL with tag. e.g., gcr.io/project-id-372417/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" - target-regurl: + target_regurl: required: true default: "" description: "Container image registry URL WITHOUT tag e.g., gcr.io/project-id-372417/target-image" @@ -17,17 +17,23 @@ jobs: name: Copy container image runs-on: ubuntu-latest env: - SOURCE_IMAGE_WITH_TAG: ${{ github.env.inputs.source-regurl-tag }} - TARGET_IMAGE_URL: ${{ github.env.inputs.target-regurl }} + IMAGE_TAG: '' + PROD_IMAGE: '' steps: + - name: print + run: | + echo ${{ inputs.source_regurl_tag }} + echo ${{ inputs.target-tag }} - name: Get image tag run: | - echo IMAGE_TAG=$(echo ${{ env.SOURCE_IMAGE_WITH_TAG }} | cut -d":" -f2) >> $GITHUB_ENV + echo IMAGE_TAG=$(echo ${{ inputs.source_regurl_tag }} | cut -d":" -f2) >> $GITHUB_ENV + echo "PROD_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV - name: Summary run: | - echo "SOURCE_IMAGE_WITH_TAG=${{ env.SOURCE_IMAGE_WITH_TAG }}" >> $GITHUB_STEP_SUMMARY - echo "PROD_IMAGE=${{ env.TARGET_IMAGE_URL }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY + echo "source_regurl_tag: ${{ inputs.source_regurl_tag }}" >> $GITHUB_STEP_SUMMARY + echo "target_regurl: ${{ inputs.target_regurl }}" >> $GITHUB_STEP_SUMMARY + echo "PROD_IMAGE: ${{ env.PROD_IMAGE }}" >> $GITHUB_STEP_SUMMARY - uses: hmarr/debug-action@v2 if: always() diff --git a/.github/workflows/dispatch-request-exmple.json b/.github/workflows/dispatch-request-exmple.json index acfe825..4387f57 100644 --- a/.github/workflows/dispatch-request-exmple.json +++ b/.github/workflows/dispatch-request-exmple.json @@ -1,7 +1,7 @@ { "ref": "develop", "inputs": { - "source-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", - "target-url": "gcr.io/project-id/target-image" + "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", + "target_regurl": "gcr.io/project-id/target-image" } } \ No newline at end of file diff --git a/README.md b/README.md index b1bcf60..f6c8517 100644 --- a/README.md +++ b/README.md @@ -71,11 +71,13 @@ Provides GitHub Workflow and Action samples. cp .github/workflows/dispatch-request-exmple.json request-body.json cat request-body.json +TOKEN="example-github_pat_XXXXX" + curl -d @request-body.json \ -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Authorization: Bearer " \ - https://github.com/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches + -H "Authorization: Bearer $TOKEN" \ + https://api.github.com/repos/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches ``` develop branch: @@ -86,8 +88,8 @@ develop branch: { "ref": "develop", "inputs": { - "test-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", - "prod-url": "gcr.io/project-id/target-image" + "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", + "target_regurl": "gcr.io/project-id/target-image" } } ``` @@ -96,10 +98,10 @@ master branch: ```json { - "ref": "develop", + "ref": "master", "inputs": { - "test-url-tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", - "prod-url": "gcr.io/project-id/target-image" + "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", + "target_regurl": "gcr.io/project-id/target-image" } } ``` From d148fb13d861aef0e652bc24d0a5e286c0b45512 Mon Sep 17 00:00:00 2001 From: engel80 Date: Sun, 15 Jan 2023 00:03:41 +0900 Subject: [PATCH 3/4] Dispatch example (#14) --- .github/workflows/dispatch-example.yml | 24 +++- README.md | 173 ++++++++----------------- app/Dockerfile | 14 ++ app/app.py | 37 ++++++ app/requirements.txt | 2 + 5 files changed, 128 insertions(+), 122 deletions(-) create mode 100644 app/Dockerfile create mode 100755 app/app.py create mode 100644 app/requirements.txt diff --git a/.github/workflows/dispatch-example.yml b/.github/workflows/dispatch-example.yml index 9c99bbd..2d6a5df 100644 --- a/.github/workflows/dispatch-example.yml +++ b/.github/workflows/dispatch-example.yml @@ -10,7 +10,7 @@ on: target_regurl: required: true default: "" - description: "Container image registry URL WITHOUT tag e.g., gcr.io/project-id-372417/target-image" + description: "Container image registry URL without tag. e.g., gcr.io/project-id-372417/target-image" jobs: copy_container_image: @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest env: IMAGE_TAG: '' - PROD_IMAGE: '' + TARGET_IMAGE: '' steps: - name: print run: | @@ -27,13 +27,29 @@ jobs: - name: Get image tag run: | echo IMAGE_TAG=$(echo ${{ inputs.source_regurl_tag }} | cut -d":" -f2) >> $GITHUB_ENV - echo "PROD_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV + echo "TARGET_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV + + - uses: 'google-github-actions/auth@v1' + with: + credentials_json: ${{ secrets.SA_A }} + + - name: Configure Docker auth for gcloud command-line + run: gcloud --quiet auth configure-docker && gcloud auth list + + - name: Pull from source image + run: docker pull ${{ inputs.source_regurl_tag }} + + - name: Tag target image + run: docker tag ${{ inputs.source_regurl_tag }} ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} + + - name: Push to target + run: docker push ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} - name: Summary run: | echo "source_regurl_tag: ${{ inputs.source_regurl_tag }}" >> $GITHUB_STEP_SUMMARY echo "target_regurl: ${{ inputs.target_regurl }}" >> $GITHUB_STEP_SUMMARY - echo "PROD_IMAGE: ${{ env.PROD_IMAGE }}" >> $GITHUB_STEP_SUMMARY + echo "TARGET_IMAGE: ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY - uses: hmarr/debug-action@v2 if: always() diff --git a/README.md b/README.md index f6c8517..2d6a5df 100644 --- a/README.md +++ b/README.md @@ -1,118 +1,55 @@ -# GitHub Actions - -[![Build](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml) -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions) - -## Overview - -Provides GitHub Workflow and Action samples. - -## Sample Repositories - -| Repository | Workflow File | Actions | Description | Plugins | -|---|--------------------------------|------|--------------------------------|---------------| -| gke-workload-identity | [build.yml](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/gke-workload-identity/actions/workflows/build.yml) | GCP, gcloud, Docker, Terraform
Python, pytest, publish unittest result, Sonarqube | hashicorp/setup-terraform@v2.0.3
jacobtomlinson/gha-find-replace@v2
actions/github-script@v6
actions/setup-java@v1
actions/setup-python@v4
google-github-actions/auth@v1
EnricoMi/publish-unit-test-result-action/composite@v2
actions/cache@v3
| -| jenkins-fargate-cdk | [build.yml](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/actions/workflows/build.yml) | Docker, CDK, Sonarqube | | - -## Docker - -- Build multi-platform docker image files: [docker-buildx-gcr.yml](docker-buildx-gcr.yml) - -## Cache - -- Optimize build speed using the `cache` plugin: [java/README.md](java/README.md) - - [java/.github/workflows/build-java.yml](java/.github/workflows/build-java.yml) - - [java/.github/workflows/build-java-sonarqube.yml](java/.github/workflows/build-java-sonarqube.yml) - -## Matrix - -- [gke-workload-identity](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml) - -## Terraform - -- [terraform.yml](terraform.yml) - -
Terraform Plan - - ![terraform-plan.png](./screenshots/terraform-plan.png?raw=true) - -
- -## Python Unittest - -- [python-unittest.yml](python-unittest.yml) [setup.cfg](setup.cfg) - -
Unittest Results - - ![test-failed.png](./screenshots/test-failed.png?raw=true) - - ![test-failed-details.png](./screenshots/test-failed-details.png?raw=true) - -
- -## Plugins - -| Plugin | Description | -|-------------|--------------------------------| -| [actions/setup-java@v3](https://github.com/actions/setup-java) | | -| [actions/setup-python@v4](https://github.com/actions/setup-python) | | -| [actions/cache@v3](https://github.com/actions/cache) | | -| [actions/github-script@v6](https://github.com/actions/github-script) | | -| [hashicorp/setup-terraform@v2.0.3](https://github.com/hashicorp/setup-terraform) | | -| [jacobtomlinson/gha-find-replace@v2](https://github.com/jacobtomlinson/gha-find-replace) | Find and Replace Action | -| [google-github-actions/auth@v1](https://github.com/google-github-actions/auth) | GitHub Action authenticates to Google Cloud | -| [EnricoMi/publish-unit-test-result-action/composite@v2](https://github.com/EnricoMi/publish-unit-test-result-action) | Publish Test Results | - -## Dispatch - -```bash -cp .github/workflows/dispatch-request-exmple.json request-body.json -cat request-body.json - -TOKEN="example-github_pat_XXXXX" - -curl -d @request-body.json \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Authorization: Bearer $TOKEN" \ - https://api.github.com/repos/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches -``` - -develop branch: - -[.github/workflows/dispatch-request-exmple.json](.github/workflows/dispatch-request-exmple.json) - -```json -{ - "ref": "develop", - "inputs": { - "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", - "target_regurl": "gcr.io/project-id/target-image" - } -} -``` - -master branch: - -```json -{ - "ref": "master", - "inputs": { - "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", - "target_regurl": "gcr.io/project-id/target-image" - } -} -``` - - -## Reference - -- [GitHub Actions /Using workflows / Cache dependencies / Caching dependencies to speed up workflows](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches) - -- https://github.com/actions/cache - -- https://github.com/actions/cache/blob/main/examples.md#java---gradle - -- https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event +name: GitHub action dispath + +on: + workflow_dispatch: + inputs: + source_regurl_tag: + required: true + default: "" + description: "Container image registry URL with tag. e.g., gcr.io/project-id-372417/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" + target_regurl: + required: true + default: "" + description: "Container image registry URL without tag. e.g., gcr.io/project-id-372417/target-image" + +jobs: + copy_container_image: + name: Copy container image + runs-on: ubuntu-latest + env: + IMAGE_TAG: '' + TARGET_IMAGE: '' + steps: + - name: print + run: | + echo ${{ inputs.source_regurl_tag }} + echo ${{ inputs.target-tag }} + - name: Get image tag + run: | + echo IMAGE_TAG=$(echo ${{ inputs.source_regurl_tag }} | cut -d":" -f2) >> $GITHUB_ENV + echo "TARGET_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV + + - uses: 'google-github-actions/auth@v1' + with: + credentials_json: ${{ secrets.SA_A }} + + - name: Configure Docker auth for gcloud command-line + run: gcloud --quiet auth configure-docker && gcloud auth list + + - name: Pull from source image + run: docker pull ${{ inputs.source_regurl_tag }} + + - name: Tag target image + run: docker tag ${{ inputs.source_regurl_tag }} ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} + + - name: Push to target + run: docker push ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} + + - name: Summary + run: | + echo "source_regurl_tag: ${{ inputs.source_regurl_tag }}" >> $GITHUB_STEP_SUMMARY + echo "target_regurl: ${{ inputs.target_regurl }}" >> $GITHUB_STEP_SUMMARY + echo "TARGET_IMAGE: ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY + + - uses: hmarr/debug-action@v2 + if: always() diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..1aba69d --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.9-alpine + +VOLUME ./:app/ + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +COPY . /app/ + +WORKDIR /app + +EXPOSE 8000 + +CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:8000"] diff --git a/app/app.py b/app/app.py new file mode 100755 index 0000000..6933309 --- /dev/null +++ b/app/app.py @@ -0,0 +1,37 @@ +from flask import Flask +from flask import request +from flask import json +from werkzeug.exceptions import HTTPException + +app = Flask(__name__) + +@app.route("/") +def ping_root(): + return ping() + +@app.route("/") +def ping_path1(path1): + return ping() + +def ping(): + return { + "host": request.host, + "url": request.url, + "method": request.method, + "message": "ping-api" + } + +@app.errorhandler(HTTPException) +def handle_exception(e): + response = e.get_response() + response.data = json.dumps({ + "code": e.code, + "name": e.name, + "description": e.description, + }) + response.content_type = "application/json" + return response + +if __name__ == '__main__': + app.debug = True + app.run(host='0.0.0.0', port=8000) diff --git a/app/requirements.txt b/app/requirements.txt new file mode 100644 index 0000000..57a72e3 --- /dev/null +++ b/app/requirements.txt @@ -0,0 +1,2 @@ +Flask==2.1.1 +gunicorn==20.1.0 \ No newline at end of file From e306aadf0d91d3905c056a1213bb20c5b8e3a2fa Mon Sep 17 00:00:00 2001 From: engel80 Date: Sun, 15 Jan 2023 00:08:14 +0900 Subject: [PATCH 4/4] . --- README.md | 174 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 119 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 2d6a5df..978f092 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,119 @@ -name: GitHub action dispath - -on: - workflow_dispatch: - inputs: - source_regurl_tag: - required: true - default: "" - description: "Container image registry URL with tag. e.g., gcr.io/project-id-372417/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2" - target_regurl: - required: true - default: "" - description: "Container image registry URL without tag. e.g., gcr.io/project-id-372417/target-image" - -jobs: - copy_container_image: - name: Copy container image - runs-on: ubuntu-latest - env: - IMAGE_TAG: '' - TARGET_IMAGE: '' - steps: - - name: print - run: | - echo ${{ inputs.source_regurl_tag }} - echo ${{ inputs.target-tag }} - - name: Get image tag - run: | - echo IMAGE_TAG=$(echo ${{ inputs.source_regurl_tag }} | cut -d":" -f2) >> $GITHUB_ENV - echo "TARGET_IMAGE=${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_ENV - - - uses: 'google-github-actions/auth@v1' - with: - credentials_json: ${{ secrets.SA_A }} - - - name: Configure Docker auth for gcloud command-line - run: gcloud --quiet auth configure-docker && gcloud auth list - - - name: Pull from source image - run: docker pull ${{ inputs.source_regurl_tag }} - - - name: Tag target image - run: docker tag ${{ inputs.source_regurl_tag }} ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} - - - name: Push to target - run: docker push ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }} - - - name: Summary - run: | - echo "source_regurl_tag: ${{ inputs.source_regurl_tag }}" >> $GITHUB_STEP_SUMMARY - echo "target_regurl: ${{ inputs.target_regurl }}" >> $GITHUB_STEP_SUMMARY - echo "TARGET_IMAGE: ${{ inputs.target_regurl }}:${{ env.IMAGE_TAG }}" >> $GITHUB_STEP_SUMMARY - - - uses: hmarr/debug-action@v2 - if: always() + +# GitHub Actions + +[![Build](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/DevSecOpsSamples/githubactions/actions/workflows/build.yml) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=DevSecOpsSamples_githubactions&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=DevSecOpsSamples_githubactions) + +## Overview + +Provides GitHub Workflow and Action samples. + +## Sample Repositories + +| Repository | Workflow File | Actions | Description | Plugins | +|---|--------------------------------|------|--------------------------------|---------------| +| gke-workload-identity | [build.yml](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/gke-workload-identity/actions/workflows/build.yml) | GCP, gcloud, Docker, Terraform
Python, pytest, publish unittest result, Sonarqube | hashicorp/setup-terraform@v2.0.3
jacobtomlinson/gha-find-replace@v2
actions/github-script@v6
actions/setup-java@v1
actions/setup-python@v4
google-github-actions/auth@v1
EnricoMi/publish-unit-test-result-action/composite@v2
actions/cache@v3
| +| jenkins-fargate-cdk | [build.yml](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/blob/master/.github/workflows/build.yml) | [actions](https://github.com/DevSecOpsSamples/jenkins-fargate-cdk/actions/workflows/build.yml) | Docker, CDK, Sonarqube | | + +## Docker + +- Build multi-platform docker image files: [docker-buildx-gcr.yml](docker-buildx-gcr.yml) + +## Cache + +- Optimize build speed using the `cache` plugin: [java/README.md](java/README.md) + + [java/.github/workflows/build-java.yml](java/.github/workflows/build-java.yml) + + [java/.github/workflows/build-java-sonarqube.yml](java/.github/workflows/build-java-sonarqube.yml) + +## Matrix + +- [gke-workload-identity](https://github.com/DevSecOpsSamples/gke-workload-identity/blob/master/.github/workflows/build.yml) + +## Terraform + +- [terraform.yml](terraform.yml) + +
Terraform Plan + + ![terraform-plan.png](./screenshots/terraform-plan.png?raw=true) + +
+ +## Python Unittest + +- [python-unittest.yml](python-unittest.yml) [setup.cfg](setup.cfg) + +
Unittest Results + + ![test-failed.png](./screenshots/test-failed.png?raw=true) + + ![test-failed-details.png](./screenshots/test-failed-details.png?raw=true) + +
+ +## Plugins + +| Plugin | Description | +|-------------|--------------------------------| +| [actions/setup-java@v3](https://github.com/actions/setup-java) | | +| [actions/setup-python@v4](https://github.com/actions/setup-python) | | +| [actions/cache@v3](https://github.com/actions/cache) | | +| [actions/github-script@v6](https://github.com/actions/github-script) | | +| [hashicorp/setup-terraform@v2.0.3](https://github.com/hashicorp/setup-terraform) | | +| [jacobtomlinson/gha-find-replace@v2](https://github.com/jacobtomlinson/gha-find-replace) | Find and Replace Action | +| [google-github-actions/auth@v1](https://github.com/google-github-actions/auth) | GitHub Action authenticates to Google Cloud | +| [EnricoMi/publish-unit-test-result-action/composite@v2](https://github.com/EnricoMi/publish-unit-test-result-action) | Publish Test Results | + +## Dispatch + +```bash +cp .github/workflows/dispatch-request-exmple.json request-body.json +cat request-body.json + +TOKEN="example-github_pat_XXXXX" + +curl -d @request-body.json \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Authorization: Bearer $TOKEN" \ + https://api.github.com/repos/DevSecOpsSamples/githubactions/actions/workflows/dispatch-example.yml/dispatches +``` + +develop branch: + +[.github/workflows/dispatch-request-exmple.json](.github/workflows/dispatch-request-exmple.json) + +```json +{ + "ref": "develop", + "inputs": { + "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", + "target_regurl": "gcr.io/project-id/target-image" + } +} +``` + +master branch: + +```json +{ + "ref": "master", + "inputs": { + "source_regurl_tag": "gcr.io/project-id/source-image:2650c2f7c04640b8c67df560510914f7ba2033e2", + "target_regurl": "gcr.io/project-id/target-image" + } +} +``` + + +## Reference + +- [GitHub Actions /Using workflows / Cache dependencies / Caching dependencies to speed up workflows](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches) + +- https://github.com/actions/cache + +- https://github.com/actions/cache/blob/main/examples.md#java---gradle + +- https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event \ No newline at end of file