Skip to content

Commit

Permalink
Merge pull request #5 from jsoref/improvements
Browse files Browse the repository at this point in the history
- Improvements on Linting
- Basic check for base64 json string
  • Loading branch information
RafikFarhad authored Dec 9, 2020
2 parents 8a692cc + d693104 commit 6f2b6bc
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM docker:19.03.8

LABEL maintainer="RafikFarhad<[email protected]>"
LABEL maintainer="RafikFarhad <[email protected]>"

RUN apk update && \
apk upgrade && \
Expand All @@ -21,4 +21,4 @@ ADD entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
ENTRYPOINT [ "/entrypoint.sh" ]
10 changes: 5 additions & 5 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Push to GCR Github Action
# Push to GCR GitHub Action

An action that build docker image and push to Google Cloud Registry.

Expand All @@ -19,7 +19,7 @@ The project id. This field is required.
The image name. This field is required.

### `image_tag`
The tag for the image. To create multiple tag of the same image, provide comma (`,`) separeted tag name (eg:`v2.1,v2,latest`).
The tag for the image. To create multiple tag of the same image, provide comma (`,`) separeted tag name (e.g. `v2.1,v2,latest`).

Default: `latest`.

Expand All @@ -42,7 +42,7 @@ Put desired yml section in the `.github/workflows/build.yml` file
### [`To perform build & push on every git push`](https://github.com/RafikFarhad/example/build.yml)

```
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on: [push]
jobs:
build-and-push-to-gcr:
Expand All @@ -59,7 +59,7 @@ jobs:
### [`To perform build & push only on tag publish`](https://github.com/RafikFarhad/example/build_only_tags.yml)

```
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on:
push:
tags:
Expand All @@ -79,4 +79,4 @@ jobs:
image_name: server-end
image_tag: ${{ steps.get_tag_name.outputs.GIT_TAG_NAME}}
dockerfile: ./build/Dockerfile
```
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GCR Github Action
name: Push to GCR GitHub Action
author: Rafik Farhad <[email protected]>
description: An action that build docker image and push to Google Cloud Registry
branding:
Expand Down
5 changes: 4 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function split_csv() {
ALL_IMAGE_TAG=()

echo "Authenticating docker to gcloud ..."
echo $INPUT_GCLOUD_SERVICE_KEY | python -m base64 -d >/tmp/key.json
if ! echo $INPUT_GCLOUD_SERVICE_KEY | python -m base64 -d >/tmp/key.json 2>/dev/null; then
echo "Failed to decode gcloud_service_key -- did you forget to encode it using 'python -m base64 -e < yourkey.json'?"
exit 1
fi

if cat /tmp/key.json | docker login -u _json_key --password-stdin https://$INPUT_REGISTRY; then
echo "Logged in to google cloud ..."
Expand Down
4 changes: 2 additions & 2 deletions example/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on: [push]
jobs:
build-and-push-to-gcr:
Expand All @@ -9,4 +9,4 @@ jobs:
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
registry: gcr.io
project_id: my-awesome-project
image_name: server-end
image_name: server-end
2 changes: 1 addition & 1 deletion example/build_all_option.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on: [push]
jobs:
build-and-push-to-gcr:
Expand Down
4 changes: 2 additions & 2 deletions example/build_only_tags.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on:
push:
tags:
Expand All @@ -17,4 +17,4 @@ jobs:
project_id: my-awesome-project
image_name: server-end
image_tag: latest,${{ steps.get_tag_name.outputs.GIT_TAG_NAME }}
dockerfile: ./build/Dockerfile
dockerfile: ./build/Dockerfile
2 changes: 1 addition & 1 deletion test/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ FROM gcc:10.1.0 AS prod
WORKDIR /root
COPY --from=build /root/executable ./executable

ENTRYPOINT ["./executable"]
ENTRYPOINT ["./executable"]
2 changes: 1 addition & 1 deletion test/HelloWorld.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
int main() {
printf("Hello World :)\n");
return 0;
}
}
2 changes: 1 addition & 1 deletion test/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ To test the action locally, [https://github.com/nektos/act](https://github.com/n

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 -v -s GCLOUD_SERVICE_KEY="$(< test/secret.txt)" -W test/` from the repository root.
4 changes: 2 additions & 2 deletions test/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GCR Github Action
name: Push to GCR GitHub Action
on: [push]
jobs:
build-and-push-to-gcr:
Expand All @@ -13,4 +13,4 @@ jobs:
image_tag: v2,latest
dockerfile: ./test/Dockerfile.test
context: ./test
target: build
target: build

0 comments on commit 6f2b6bc

Please sign in to comment.