Skip to content

Commit 0115106

Browse files
committed
ci: Updated github workflows and added documentation
1 parent e716c9c commit 0115106

5 files changed

Lines changed: 133 additions & 6 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Multi-Platform Docker Build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
# Step 1: Check out the repository and submodules
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
with:
15+
submodules: true # Fetch submodules
16+
fetch-depth: 0 # Ensure the full history is fetched
17+
18+
# Step 2: Set up Docker Buildx
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v2
21+
22+
# Step 3: Install yq
23+
- name: Install yq
24+
run: |
25+
sudo apt-get update && sudo apt-get install -y wget
26+
sudo wget https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 -O /usr/bin/yq
27+
sudo chmod +x /usr/bin/yq
28+
29+
# Step 4: Extract component-version and component-name from odtp.yml
30+
- name: Extract component-version and component-name
31+
id: extract_info
32+
run: |
33+
VERSION=$(yq e '.component-version' odtp.yml)
34+
NAME=$(yq e '.component-name' odtp.yml)
35+
echo "VERSION=${VERSION}"
36+
echo "NAME=${NAME}"
37+
echo "COMPONENT_VERSION=${VERSION}" >> $GITHUB_ENV
38+
echo "COMPONENT_NAME=${NAME}" >> $GITHUB_ENV
39+
40+
# Step 5: Log in to GitHub Container Registry
41+
- name: Log in to GitHub Container Registry
42+
uses: docker/login-action@v2
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
# Step 6: Build and push Docker image for multiple platforms
49+
- name: Build and push Docker image
50+
run: |
51+
IMAGE_NAME=ghcr.io/${{ github.repository }}/${{ env.COMPONENT_NAME }}
52+
docker buildx build \
53+
--platform linux/amd64,linux/arm64 \
54+
--build-arg COMPONENT_VERSION=${{ env.COMPONENT_VERSION }} \
55+
-t $IMAGE_NAME:${{ env.COMPONENT_VERSION }} \
56+
-t $IMAGE_NAME:latest \
57+
--push .
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Multi-Platform Docker Build for Dockerhub
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
# Step 1: Check out the repository and submodules
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
with:
15+
submodules: true # Fetch submodules
16+
fetch-depth: 0 # Ensure the full history is fetched
17+
18+
# Step 2: Set up Docker Buildx
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v2
21+
22+
# Step 3: Install yq
23+
- name: Install yq
24+
run: |
25+
sudo apt-get update && sudo apt-get install -y wget
26+
sudo wget https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 -O /usr/bin/yq
27+
sudo chmod +x /usr/bin/yq
28+
29+
# Step 4: Extract component-version and component-name from odtp.yml
30+
- name: Extract component-version and component-name
31+
id: extract_info
32+
run: |
33+
VERSION=$(yq e '.component-version' odtp.yml)
34+
NAME=$(yq e '.component-name' odtp.yml)
35+
echo "VERSION=${VERSION}"
36+
echo "NAME=${NAME}"
37+
echo "COMPONENT_VERSION=${VERSION}" >> $GITHUB_ENV
38+
echo "COMPONENT_NAME=${NAME}" >> $GITHUB_ENV
39+
40+
# Step 5: Log in to Docker Hub
41+
- name: Log in to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKER_USERNAME }}
45+
password: ${{ secrets.DOCKER_PASSWORD }}
46+
47+
# Step 6: Build and push Docker image for multiple platforms
48+
- name: Build and push Docker image
49+
run: |
50+
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ env.COMPONENT_NAME }}
51+
docker buildx build \
52+
--platform linux/amd64,linux/arm64 \
53+
--build-arg COMPONENT_VERSION=${{ env.COMPONENT_VERSION }} \
54+
-t $IMAGE_NAME:${{ env.COMPONENT_VERSION }} \
55+
-t $IMAGE_NAME:latest \
56+
--push .

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ This is a component used to test ODTP components. It uses Hugging face datasets,
1111
```
1212
odtp new odtp-component-entry \
1313
--name odtp-example \
14-
--component-version 0.1.0 \
15-
--repository https://github.com/odtp-org/odtp-component-example \
16-
--commit a30858fe0997c839130f0e31583232caa143c79c
14+
--component-version v0.1.5 \
15+
--repository https://github.com/odtp-org/odtp-component-example
1716
```
1817

1918
## Tutorial
@@ -42,16 +41,31 @@ mkdir odtp-component-example-execution
4241
cd odtp-component-example-execution
4342
mkdir odtp-input
4443
mkdir odtp-output
44+
mkdir odtp-logs
4545
```
4646

4747
5. Run the following command.
4848

4949
```
50-
docker run -it --rm -v [Absolute Path to your input folder]:/odtp/odtp-input -v [Absolute Path to your output folder]:/odtp/odtp-output --env-file .env odtp-component-example
50+
docker run -it --rm \
51+
-v $(pwd)/odtp-input:/odtp/odtp-input \
52+
-v $(pwd)/odtp-output:/odtp/odtp-output \
53+
-v $(pwd)/odtp-logs:/odtp/odtp-logs \
54+
--env-file .env odtp-component-example
5155
```
5256

5357
## Changelog
5458

59+
- v0.1.5
60+
- Updated ODTP Client
61+
- Including workflows
62+
63+
- v0.1.4
64+
65+
- v0.1.3
66+
67+
- v0.1.2
68+
5569
- v0.1.1: Change Dockerfile setup: use fixed versions for python and ubuntu
5670

5771
- v0.1.0: Basic functionality

odtp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file should contain basic component information for your component.
22
component-name: odtp-eqasim-matsim
33
component-author: Carlos Vivar Rios
4-
component-version: 0.1.0
4+
component-version: v0.1.5
55
component-repository: https://github.com/odtp-org/odtp-component-example
66
component-license: AGPL-3.0
77
component-type: ephemeral

0 commit comments

Comments
 (0)