Skip to content

Commit

Permalink
Merge pull request #23 from sustainable-computing-io/gitworkflow
Browse files Browse the repository at this point in the history
initial workflow
  • Loading branch information
trent-s authored Dec 7, 2023
2 parents 5042ff0 + 6051d7c commit b4e19bc
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/compute-version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Compute Version
description: computes version of the operator
outputs:
version:
description: "operator version"
value: ${{ steps.version.outputs.version }}
runs:
using: composite
steps:
- name: Generate Version
id: version
shell: bash
run: |
version="$(cat VERSION)-$(date +%Y%m%d%H%M%S)"
echo VERSION=$version
echo "version=$version" >> $GITHUB_OUTPUT
58 changes: 58 additions & 0 deletions .github/publish-images/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Publish Images
description: "Publishes operator and bundle images to an Image Registry"
inputs:
image_registry:
description: "image registry"
required: true
registry_login:
description: "registry username"
required: true
registry_token:
description: "registry token"
required: true

version:
description: "operator version"
required: true

additional_tags:
description: "additional tags for container images"
required: false
runs:
using: composite
steps:
- name: Checkout source
uses: actions/checkout@v3

- uses: actions/setup-go@main
with:
go-version-file: go.mod
check-latest: true
cache: true

- name: Login to Image Registry
uses: docker/login-action@v2
if: "!startsWith(inputs.image_registry, 'localhost')"
with:
registry: ${{ inputs.image_registry }}
username: ${{ inputs.registry_login }}
password: ${{ inputs.registry_token }}

- name: Build Operator
shell: bash
run: |
make build
env:
VERSION: ${{ inputs.version }}
IMG: ${{ inputs.image_registry }}
ADDITIONAL_TAGS: ${{ inputs.additional_tags }}

- name: Push Images
shell: bash
if: "!startsWith(inputs.image_registry, 'localhost')"
run: |
make docker-build docker-push
env:
VERSION: ${{ inputs.version }}
IMG: ${{ inputs.image_registry }}
ADDITIONAL_TAGS: ${{ inputs.additional_tags }}
36 changes: 36 additions & 0 deletions .github/workflows/publish-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Images

on:
push:
branches: [ v1alpha1 ]

jobs:
publish:
name: Publish operator container images
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3

- uses: actions/setup-go@main
with:
go-version-file: go.mod
cache: true

- uses: ./.github/compute-version
id: version

- name: additional tags
id: additional_tags
shell: bash
run: |
echo "result=$(git rev-parse --short HEAD),v1alpha1" >> $GITHUB_OUTPUT
- name: build and publish images to external registry
uses: ./.github/publish-images
with:
image_registry: ${{ vars.IMG_BASE }}
registry_login: ${{ secrets.BOT_NAME }}
registry_token: ${{ secrets.BOT_TOKEN }}
version: ${{ steps.version.outputs.version }}
additional_tags: ${{ steps.additional_tags.outputs.result }}
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0

0 comments on commit b4e19bc

Please sign in to comment.