Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

refactor ci.yaml Action's environment variables #110

Merged
merged 3 commits into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on: # yamllint disable-line rule:truthy
types: [opened, synchronize, reopened, ready_for_review]

env:
GO_VERSION: 1.22
QUAY_NAMESPACE: ${{ vars.QUAY_NAMESPACE || 'konflux-workspaces' }}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -21,9 +21,12 @@ jobs:
matrix:
include:
- directory: server
image_base: quay.io/konflux-workspaces/workspaces-server
image_base: workspaces-server
- directory: operator
image_base: quay.io/konflux-workspaces/workspaces-operator
image_base: workspaces-operator

env:
GO_VERSION: 1.22

steps:
- name: Checkout Git Repository
Expand All @@ -46,14 +49,20 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Compute base image
id: img
run: |
IMG="quay.io/${{ env.QUAY_NAMESPACE }}/${{ matrix.image_base }}"
echo "base=${IMG}" >> ${GITHUB_OUTPUT}

- name: Build image
id: tag
run: |
if [[ "${GITHUB_EVENT_NAME}" = "pull_request_target" ]]; then
export PR_SHA=${{ github.event.pull_request.head.sha }}
export IMG="${{ matrix.image_base }}:pr-${{ github.event.pull_request.number }}-${PR_SHA:0:8}"
export IMG="${{ steps.img.outputs.base }}:pr-${{ github.event.pull_request.number }}-${PR_SHA:0:8}"
else
export IMG="${{ matrix.image_base }}:${GITHUB_SHA:0:8}"
export IMG="${{ steps.img.outputs.base }}:${GITHUB_SHA:0:8}"
fi
echo "tag=${IMG}" >> ${GITHUB_OUTPUT}
make -C "${{ matrix.directory }}" docker-build
Expand All @@ -73,13 +82,16 @@ jobs:
password: ${{ secrets.QUAY_TOKEN }}

- name: Push images
run: docker push -a ${{ matrix.image_base }}
run: docker push -a "${{ steps.img.outputs.base }}"

build-kubesaw:
name: Build kubesaw components
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request_target' }}

env:
GO_VERSION: 1.20.8

steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
Expand All @@ -93,7 +105,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.20.8
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Prepare tools
Expand All @@ -109,6 +121,7 @@ jobs:
- name: Build and push images
env:
PR_SHA: ${{ github.event.pull_request.head.sha }}
IMAGE_BUILDER: docker
run: |
export TAG=pr-${{ github.event.pull_request.number }}-${PR_SHA:0:8}
IMAGE_BUILDER=docker ci/toolchain_manager.sh "${TAG}"
ci/toolchain_manager.sh "${TAG}"
Loading