-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Action added * Rename folder * unnecessary step removed * chore: clean 🧽 * Self test * correct use + syntax fixed * debug * debug * debug * fixed action path * try fixing path * try fixing path again * SHA added with image scan * Docker scan fixed * removed docekr scan * Test job added * dep added * docker login for test step * Step naming * Remove docker images added * Fix test script * Fix docker remove step * Remove from GCR instead of local docker * Comment for example case * Fix warning * Uses checkout for google-github-actions/auth warning * Support for plain text key file * Change default to plain text * ReadMe updated * Example updated for v4.1 * ReadMe updated * Better image_tag handling * Empty image tag handling fixed * python version updated
- Loading branch information
1 parent
920e46c
commit 2417078
Showing
11 changed files
with
99 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Push to GCR GitHub Action | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
build-and-push-to-gcr: | ||
name: "Bulding and pushing images" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: "Building and pushing the image" | ||
uses: ./ | ||
with: | ||
gcloud_service_key: ${{ secrets.JSON_GCLOUD_SERVICE_ACCOUNT_JSON }} | ||
registry: gcr.io | ||
project_id: pro-chesta | ||
image_name: hello-world-by-push-to-gcr | ||
image_tag: test-${{ github.sha }}, ${{ github.sha }} | ||
dockerfile: ./test/Dockerfile.test | ||
context: ./test | ||
target: build | ||
# If you are checking this file to use this action in your project, | ||
# you only need the first step 👆. | ||
# The following two steps are needed to test this action. | ||
test-image: | ||
name: "Testing the image" | ||
needs: [build-and-push-to-gcr] | ||
runs-on: ubuntu-latest | ||
container: | ||
image: "gcr.io/pro-chesta/hello-world-by-push-to-gcr:${{ github.sha }}" | ||
credentials: | ||
username: _json_key | ||
password: ${{ secrets.JSON_GCLOUD_SERVICE_ACCOUNT_JSON }} | ||
steps: | ||
- name: "Testing the image" | ||
run: exit $([ "$(/root/executable)" = "Hello World from Push To GCR github action" ]) | ||
cleanup: | ||
name: "Cleaning up images" | ||
needs: [build-and-push-to-gcr, test-image] | ||
if: always() | ||
continue-on-error: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: 'Authenticate to Google Cloud' | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
credentials_json: '${{ secrets.JSON_GCLOUD_SERVICE_ACCOUNT_JSON }}' | ||
- name: "Delete images" | ||
run: gcloud container images delete gcr.io/pro-chesta/hello-world-by-push-to-gcr:${{ github.sha }} --force-delete-tags --quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
printf("Hello World :)\n"); | ||
printf("Hello World from Push To GCR github action"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Local Test | ||
|
||
To test the action locally, [https://github.com/nektos/act](https://github.com/nektos/act) can be useful. | ||
To test the action locally, [Act](https://github.com/nektos/act) can be useful. | ||
|
||
## Steps: | ||
|
||
1. Create a `secret.txt` file with the `base64` representation of GCloud Service Account json key in `./test` folder. | ||
2. Change `project_id`, `image_name`, `image_tag` in the `./test/build.yml` as your GCP project. | ||
2. Run `act -v -s GCLOUD_SERVICE_KEY="$(< test/secret.txt)" -W test/` from the repository root. | ||
2. Run `act -s B64_GCLOUD_SERVICE_ACCOUNT_JSON="$(cat THE_JSON_FILE | python3 -m base64 -e)" -s JSON_GCLOUD_SERVICE_ACCOUNT_JSON="$(cat THE_JSON_FILE)"` from the repository root. |
This file was deleted.
Oops, something went wrong.