From 3ab8cacf35572ce8ba74db2e96b8d6d3f8f8c943 Mon Sep 17 00:00:00 2001 From: pavlospt Date: Fri, 8 Dec 2023 10:52:35 +0200 Subject: [PATCH] Refactor after fork in Blueground org --- .github/FUNDING.yml | 1 - .github/workflows/main.yml | 40 +++++++++++++++++++++++------------ .github/workflows/release.yml | 39 +++++++++++++++++++++------------- Dockerfile | 8 +++---- README.md | 20 +++++++++--------- 5 files changed, 63 insertions(+), 45 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index d788631..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: [chuhlomin] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df7801e..45842f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,25 +6,38 @@ on: - main env: - DOCKER_IMAGE: pavlospt/render-template + DOCKER_IMAGE_REPO: bluegroundltd/render-template + PUBLIC_ECR_REGISTRY: public.ecr.aws/l2j5o5b6 jobs: main: - runs-on: ubuntu-latest + runs-on: arc-runner-set + permissions: + id-token: write + contents: read steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Build and push Docker image - uses: chuhlomin/actions/docker-build-push@main + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 with: - username: pavlospt - password: ${{ secrets.DOCKER_PASSWORD }} - image_name: ${{ env.DOCKER_IMAGE }} - tags: | - ${{ env.DOCKER_IMAGE }}:${{ github.sha }} - ${{ env.DOCKER_IMAGE }}:latest - + role-to-assume: arn:aws:iam::489098123993:role/github-actions-assumable-role + aws-region: eu-west-1 + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 + with: + registry-type: public + - uses: benjlevesque/short-sha@v2.2 + id: short-sha + with: + length: 7 + - name: Build & push to public ECR + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ env.PUBLIC_ECR_REGISTRY}}/${{ env.DOCKER_IMAGE_REPO }}:${{ steps.short-sha.outputs.sha }} - name: Test action uses: ./ # Uses an action in the root directory id: render @@ -32,6 +45,5 @@ jobs: template: ./testdata/template.txt vars: | name: world - - name: Get `result` output run: echo "${{ steps.render.outputs.result }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc2a4ef..ccf4c52 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,36 +6,45 @@ on: - '*' env: - DOCKER_IMAGE: pavlospt/render-template + DOCKER_IMAGE_REPO: bluegroundltd/render-template + PUBLIC_ECR_REGISTRY: public.ecr.aws/l2j5o5b6 jobs: release: - runs-on: ubuntu-latest + runs-on: arc-runner-set + permissions: + id-token: write + contents: read steps: - name: Checkout - uses: actions/checkout@v3 - + uses: actions/checkout@v4 - name: Get the tag id: get_tag run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT - - - name: Build and push Docker image - uses: chuhlomin/actions/docker-build-push@main + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::489098123993:role/github-actions-assumable-role + aws-region: eu-west-1 + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 with: - username: pavlospt - password: ${{ secrets.DOCKER_PASSWORD }} - image_name: ${{ env.DOCKER_IMAGE }} - tags: ${{ env.DOCKER_IMAGE }}:${{ steps.get_tag.outputs.tag }} + registry-type: public + - name: Build & push to public ECR + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ env.PUBLIC_ECR_REGISTRY}}/${{ env.DOCKER_IMAGE_REPO }}:${{ steps.get_tag.outputs.tag }} update-tag: - runs-on: ubuntu-latest - environment: v1 # requires approval + runs-on: arc-runner-set needs: release if: startsWith(github.ref, 'refs/tags/v1.') steps: - name: Checkout - uses: actions/checkout@v3 - + uses: actions/checkout@v4 - name: Update v1 tag shell: bash run: | diff --git a/Dockerfile b/Dockerfile index e822b40..10edbe8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,14 +7,12 @@ RUN go test -mod=vendor -cover ./... RUN go build -mod=vendor -o /go/bin/app FROM --platform=linux/arm64 gcr.io/distroless/static -# latest-amd64 -> 966f4bd97f611354c4ad829f1ed298df9386c2ec -# https://github.com/GoogleContainerTools/distroless/tree/master/base LABEL name="render-template" -LABEL repository="http://github.com/chuhlomin/render-template" -LABEL homepage="http://github.com/chuhlomin/render-template" +LABEL repository="http://github.com/bluegroundltd/render-template" +LABEL homepage="http://github.com/bluegroundltd/render-template" -LABEL maintainer="Konstantin Chukhlomin " +LABEL maintainer="BluegroundLTD " LABEL com.github.actions.name="Render template" LABEL com.github.actions.description="Renders file based on template and passed variables" LABEL com.github.actions.icon="file-text" diff --git a/README.md b/README.md index a605a8f..3459ec8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Render Template -[![main](https://github.com/chuhlomin/render-template/actions/workflows/main.yml/badge.svg)](https://github.com/chuhlomin/render-template/actions/workflows/main.yml) -[![release](https://github.com/chuhlomin/render-template/actions/workflows/release.yml/badge.svg)](https://github.com/chuhlomin/render-template/actions/workflows/release.yml) -[![DockerHub](https://img.shields.io/badge/docker-hub-4988CC)](https://hub.docker.com/repository/docker/chuhlomin/render-template) +[![main](https://github.com/bluegroundltd/render-template/actions/workflows/main.yml/badge.svg)](https://github.com/bluegroundltd/render-template/actions/workflows/main.yml) +[![release](https://github.com/bluegroundltd/render-template/actions/workflows/release.yml/badge.svg)](https://github.com/bluegroundltd/render-template/actions/workflows/release.yml) +[Public ECR](https://gallery.ecr.aws/l2j5o5b6/bluegroundltd/render-template) GitHub Action to render file based on template and passed variables. @@ -16,24 +16,24 @@ GitHub Action to render file based on template and passed variables. | result_path | Desired path to result file | false | | timezone | Timezone to use in `date` template function | false | -You must set at least `vars` or `vars_path`. +You must set at least `vars` or `vars_path`. You may set both of them (`vars` values will precede over `vars_path`). Variables names must be alphanumeric strings (must not contain any hyphens). There are few template functions available: -- `date` – formats timestamp using Go's [time layout](https://golang.org/pkg/time/#pkg-constants). - Example: `{{ "2023-05-11T01:42:04Z" | date "2006-01-02" }}` will be rendered as `2023-05-11`. +- `date` – formats timestamp using Go's [time layout](https://golang.org/pkg/time/#pkg-constants). + Example: `{{ "2023-05-11T01:42:04Z" | date "2006-01-02" }}` will be rendered as `2023-05-11`. You may use `timezone` input to set timezone for `date` function (e.g. `timezone: "America/New_York"`). -- `mdlink` – creates markdown link. +- `mdlink` – creates markdown link. Example: `{{ "https://github.com" | mdlink "GitHub" }}` will be rendered as `[GitHub](https://github.com)`. -- `number` – formats number in English locale. +- `number` – formats number in English locale. Example: `{{ 1234567890 | number }}` will be rendered as `1,234,567,890`. -- `base64` – encodes string to base64. +- `base64` – encodes string to base64. Example: `{{ "hello" | base64 }}` will be rendered as `aGVsbG8=`. ## Outputs @@ -92,7 +92,7 @@ jobs: - name: Render template id: render_template - uses: chuhlomin/render-template@v1 + uses: bluegroundltd/render-template@v2 with: template: kube.template.yml vars: |