-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(simplify): Use jobs instead of workflow dependencies
Workflow dependencies relies on a single dependency, which make build pipeline for multiple docker containers complex and most of the time erratic. Move to single jobs dependency based with a internal action to check and build images if needed improve the logic of the process and allow to visually see the running pipeline. The pipeline will run on following cases: - On pull_request if .versions file was touches, but not publishing images on the registry. - On push or workflow_dispatch, publishing to ghcr.io registry. Signed-off-by: Helio Chissini de Castro <[email protected]>
- Loading branch information
1 parent
302fd9f
commit f7b02db
Showing
32 changed files
with
443 additions
and
1,243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# License-Filename: LICENSE | ||
|
||
name: "ORT Docker Image" | ||
description: "Check and create docker image for Ort components" | ||
author: "Helio Chissini de Castro <[email protected]>" | ||
|
||
inputs: | ||
registry: | ||
description: "GitHub Container Registry" | ||
default: "ghcr.io" | ||
token: | ||
description: "GitHub token" | ||
required: true | ||
name: | ||
description: "Image name" | ||
required: true | ||
version: | ||
description: "Image version" | ||
required: true | ||
build-args: | ||
description: "List of build-time variables" | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Install Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
cache: 'pip' | ||
|
||
- name: Check if Docker image tag exists | ||
id: check_image | ||
shell: bash | ||
env: | ||
INPUT_REGISTRY: ${{ inputs.registry }} | ||
INPUT_TOKEN: ${{ inputs.token }} | ||
INPUT_NAME: ${{ inputs.name }} | ||
INPUT_VERSION: ${{ inputs.version }} | ||
run: | | ||
pip install -q -U pip requests | ||
result=$(python ./.github/actions/ortdocker/check_image.py) | ||
echo $result | ||
echo "result=$result" >> $GITHUB_OUTPUT | ||
- name: Set up Docker Buildx | ||
if: steps.check_image.outputs.result != 'found' | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: steps.check_image.outputs.result != 'found' | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.registry }} | ||
username: ${{ github.actor }} | ||
password: ${{ inputs.token }} | ||
|
||
- name: Extract components metadata (tags, labels) for base image | ||
if: steps.check_image.outputs.result != 'found' | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.REGISTRY }}/${{ github.repository }}/${{ inputs.name }} | ||
tags: | ||
type=raw,value=${{ inputs.version }} | ||
|
||
- name: Build ORT Base container | ||
if: steps.check_image.outputs.result != 'found' | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
target: ${{ inputs.name }} | ||
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
load: false | ||
build-args: ${{ inputs.build-args }} | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
${{ env.REGISTRY }}/${{ github.repository }}/${{ inputs.name }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# License-Filename: LICENSE | ||
|
||
import os | ||
|
||
import requests | ||
|
||
token = os.getenv("INPUT_TOKEN") | ||
org = os.getenv("GITHUB_REPOSITORY_OWNER") | ||
name = os.getenv("INPUT_NAME") | ||
version = os.getenv("INPUT_VERSION") | ||
|
||
url = f"https://api.github.com/orgs/{org}/packages/container/ort%2F{name}/versions" | ||
|
||
headers = { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": f"Bearer {token}", | ||
} | ||
response = requests.get(url, headers=headers) | ||
if response.status_code == 404: | ||
print("none") | ||
else: | ||
versions = [ | ||
item | ||
for sublist in [v["metadata"]["container"]["tags"] for v in response.json()] | ||
if sublist | ||
for item in sublist | ||
] | ||
if version in versions: | ||
print("found") | ||
else: | ||
print("none") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.