Skip to content

Commit

Permalink
Refactor after fork in Blueground org
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlospt committed Dec 8, 2023
1 parent b8f9c2e commit 269641e
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 51 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

40 changes: 26 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,44 @@ 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: us-east-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
with:
template: ./testdata/template.txt
vars: |
name: world
- name: Get `result` output
run: echo "${{ steps.render.outputs.result }}"
48 changes: 28 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,48 @@ 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: us-east-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.')
if: startsWith(github.ref, 'refs/tags/v2.')
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Update v1 tag
uses: actions/checkout@v4
- name: Update v2 tag
shell: bash
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "gha@chuhlomin.com"
git tag -f v1
git push -f origin v1
git tag -f v2
git push -f origin v2
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mail@chuhlomin.com>"
LABEL maintainer="BluegroundLTD <engineering@bluegroundltd.com>"
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"
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ outputs:

runs:
using: docker
image: 'Dockerfile'
image: 'docker://public.ecr.aws/l2j5o5b6/bluegroundltd/render-template:v2'

0 comments on commit 269641e

Please sign in to comment.