Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into teehr-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
samlamont committed Nov 8, 2024
2 parents d69358e + 9ba92c1 commit 21aa80b
Show file tree
Hide file tree
Showing 12 changed files with 308 additions and 635 deletions.
21 changes: 16 additions & 5 deletions .github/action_templates/build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ inputs:
platform:
description: 'The platform to build'
required: false

outputs:
tag-name:
description: "The tag name used for the image"
value: ${{ steps.set-outputs.outputs.tag-name }}

runs:
using: "composite"
Expand All @@ -31,12 +36,18 @@ runs:
run: |
echo "TAG_NAME=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
if: ${{ !startsWith(github.ref, 'refs/heads/main') }}

- name: Set outputs
id: set-outputs
shell: bash
run: |
echo "Current TAG_NAME from env: ${{ env.TAG_NAME }}"
echo "tag-name=${{ env.TAG_NAME }}" >> $GITHUB_OUTPUT
- name: Attach platform to tag
shell: bash
run: |
echo "TAG_NAME=${{env.TAG_NAME}}-${{inputs.platform}}" >> "$GITHUB_ENV"
if: "${{ inputs.platform != 'ARM64' }}"
- name: Login to Docker Hub
shell: bash
Expand All @@ -49,17 +60,17 @@ runs:
docker buildx create --use --name mybuilder --node mybuilder
- name: Build and Cache Docker Image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: ./docker
file: ./docker/${{ inputs.dockerfile-name}}
build-args: |
TAG_NAME=${{ env.TAG_NAME}}
push: true
tags: |
awiciroh/${{ inputs.image-name}}:${{ env.TAG_NAME}}
builder: mybuilder
no-cache: true
platforms: linux/${{ inputs.platform }}
provenance: false
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_CLI_EXPERIMENTAL: enabled
30 changes: 27 additions & 3 deletions .github/action_templates/build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ inputs:
platform:
description: 'The platform to build'
required: false

outputs:
tag-name:
description: "The tag name used for the image"
value: ${{ steps.set-outputs.outputs.tag-name }}

runs:
using: "composite"
Expand All @@ -31,11 +36,30 @@ runs:
run: |
echo "TAG_NAME=${GITHUB_REF##*/}" >> "$GITHUB_ENV"
if: ${{ !startsWith(github.ref, 'refs/heads/main') }}

- name: Set outputs
id: set-outputs
shell: bash
run: |
echo "Current TAG_NAME from env: ${{ env.TAG_NAME }}"
echo "tag-name=${{ env.TAG_NAME }}" >> $GITHUB_OUTPUT
- name: Attach platform to tag
shell: bash
run: |
echo "TAG_NAME=${{env.TAG_NAME}}-${{inputs.platform}}" >> "$GITHUB_ENV"
if: "${{ inputs.platform != 'ARM64' }}"
- name: Login to Docker Hub
shell: bash
run: |
echo "Logging in to Docker Hub..."
if ! echo "${{ inputs.docker-auth-token }}" | docker login --username awiciroh --password-stdin; then
echo "Failed to login to Docker Hub"
exit 1
fi
echo "Successfully logged in to Docker Hub"
docker info
- name: Create Cache and Builder for Buildx
shell: bash
run: |
Expand All @@ -46,13 +70,13 @@ runs:
with:
context: ./docker
file: ./docker/${{ inputs.dockerfile-name}}
build-args: |
TAG_NAME=${{ env.TAG_NAME}}
push: true
tags: |
awiciroh/${{ inputs.image-name}}:${{ env.TAG_NAME}}
builder: mybuilder
no-cache: true
platforms: linux/${{ inputs.platform }}
provenance: false
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/docker_deps_image.yml

This file was deleted.

103 changes: 74 additions & 29 deletions .github/workflows/docker_image_main_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
start-runner:
runs-on: ubuntu-latest
steps:
- name: start runner
- name: start arm runner
uses: gagoar/invoke-aws-lambda@master
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -19,6 +19,15 @@ jobs:
if: startsWith(github.event.pull_request.head.repo.full_name, 'CIROH-UA') ||
(startsWith(github.ref, 'refs/heads/main') && github.event_name != 'pull_request')

- name: start x86 runner
uses: gagoar/invoke-aws-lambda@master
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FunctionName: StartCirohX86Runner
if: startsWith(github.event.pull_request.head.repo.full_name, 'CIROH-UA') ||
(startsWith(github.ref, 'refs/heads/main') && github.event_name != 'pull_request')

- name: wait runner up
shell: bash
run: |
Expand All @@ -27,65 +36,95 @@ jobs:
(startsWith(github.ref, 'refs/heads/main') && github.event_name != 'pull_request')
init:
needs: start-runner
runs-on: ARM64
runs-on: ${{ matrix.runner}}
strategy:
matrix:
runner: [ARM64, AMD64]
steps:
- name: clear docker cache
run: |
docker system prune -af
deps:
build:
needs: init
uses: ./.github/workflows/docker_deps_image.yml
with:
runner_label: ARM64
secrets: inherit
troute:
needs: deps
uses: ./.github/workflows/docker_troute_image.yml
with:
runner_label: ARM64
secrets: inherit
ngen:
needs: troute
uses: ./.github/workflows/docker_ngen_image.yml
with:
runner_label: ARM64
secrets: inherit
final:
needs: ngen
runs-on: ARM64
runs-on: ${{ matrix.runner}}
outputs: # Define job outputs
test-tag-name: ${{ steps.test-build.outputs.tag-name }}
push-tag-name: ${{ steps.push-build.outputs.tag-name }}
strategy:
matrix:
runner: [arm64, amd64]
steps:
- name: deploy
uses: actions/checkout@v2
- name: Build and test Docker image
id: test-build
uses: ./.github/action_templates/build-and-test
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
image-name: "ciroh-ngen-image"
dockerfile-name: "Dockerfile"
platform: ARM64
platform: ${{ matrix.runner}}
if: ${{ !startsWith(github.ref, 'refs/heads/main') }}
- name: Build and push Docker image
id: push-build
uses: ./.github/action_templates/build-and-push
with:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
image-name: "ciroh-ngen-image"
dockerfile-name: "Dockerfile"
platform: ARM64
platform: ${{ matrix.runner}}
if: startsWith(github.ref, 'refs/heads/main')
check_result:
needs: final
runs-on: ARM64
needs: build
runs-on: ${{ matrix.runner}}
strategy:
matrix:
runner: [ARM64, AMD64]
outputs:
output1: ${{ steps.step1.outputs.result }}
steps:
- id: step1
run: echo "result=success" >> "$GITHUB_OUTPUT"

create-manifest:
needs: [check_result, build]
runs-on: ARM64
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: awiciroh
password: ${{ secrets.DOCKER_AUTH_TOKEN }}

- name: Create and push manifest
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Using push tag (main branch)"
TAG_NAME="${{ needs.build.outputs.push-tag-name }}"
else
echo "Using test tag (non-main branch)"
TAG_NAME="${{ needs.build.outputs.test-tag-name }}"
if [[ -z "${TAG_NAME}" ]]; then
echo "Error: test tag is empty"
exit 1
fi
fi
echo "Creating manifest with TAG_NAME: ${TAG_NAME}"

# Remove existing manifest if exists
docker manifest rm awiciroh/ciroh-ngen-image:${TAG_NAME} || true

docker manifest create --amend awiciroh/ciroh-ngen-image:${TAG_NAME} \
awiciroh/ciroh-ngen-image:${TAG_NAME}-arm64 \
awiciroh/ciroh-ngen-image:${TAG_NAME}-amd64
docker manifest push awiciroh/ciroh-ngen-image:${TAG_NAME}

slack:
runs-on: ARM64
if: startsWith(github.event.pull_request.head.repo.full_name, 'CIROH-UA') ||
(startsWith(github.ref, 'refs/heads/main') && github.event_name != 'pull_request')
needs: [deps, troute, ngen, final, check_result]
needs: [build, check_result,create-manifest]
env:
OUTPUT: ${{needs.check_result.outputs.output1}}
steps:
Expand Down Expand Up @@ -115,9 +154,15 @@ jobs:
if: startsWith(github.event.pull_request.head.repo.full_name, 'CIROH-UA') ||
(startsWith(github.ref, 'refs/heads/main') && github.event_name != 'pull_request')
steps:
- name: stop runner
- name: stop arm runner
uses: gagoar/invoke-aws-lambda@master
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FunctionName: StopCirohRunner
- name: stop x86 runner
uses: gagoar/invoke-aws-lambda@master
with:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FunctionName: StopCirohRunner
FunctionName: StopCirohX86Runner
80 changes: 0 additions & 80 deletions .github/workflows/docker_image_main_x86.yml

This file was deleted.

Loading

0 comments on commit 21aa80b

Please sign in to comment.