Skip to content

Commit

Permalink
Merge pull request #75 from firstbatchxyz/fco/ci
Browse files Browse the repository at this point in the history
added ci for docker build n push
  • Loading branch information
erhant authored Aug 12, 2024
2 parents b40c116 + 2dd3965 commit 1d334d0
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 2 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build_dev_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create Dev Image
on:
push:
branches: ["master"]

jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get Unix Time
id: timestamp
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT

- name: Get SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Get Branch Name
id: branch
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT

- name: Set Image Tag
id: itag
run: echo "itag=${{ steps.branch.outputs.branch }}-${{ steps.sha.outputs.sha }}-${{ steps.timestamp.outputs.timestamp }}" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v6
env:
IMAGE_TAG: ${{ steps.itag.outputs.itag }}
with:
platforms: linux/amd64, linux/arm64, linux/arm
push: true
tags: |
firstbatch/dkn-compute-node:unstable
firstbatch/dkn-compute-node:${{ env.IMAGE_TAG }}
68 changes: 68 additions & 0 deletions .github/workflows/build_prod_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create Prod Image
on:
release:
types: [published]

jobs:
check-release:
name: Check Release
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.set_tag.outputs.itag }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set Image Tag
id: itag
run: echo "itag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT

- name: Check Release Tag
run: |
if [[ ! "${{ steps.itag.outputs.itag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release tag format is invalid. It should follow the pattern 'vMAJOR.MINOR.PATCH' (e.g., v1.0.0)."
exit 1
fi
echo "Release tag format is valid."
- name: Check Cargo.toml Version
run: |
CARGO_VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION=${{ steps.itag.outputs.itag }}
TAG_VERSION=${TAG_VERSION#"v"} # Remove the leading 'v' from the tag
if [[ "$CARGO_VERSION" != "$TAG_VERSION" ]]; then
echo "Version in Cargo.toml ($CARGO_VERSION) does not match the release tag version ($TAG_VERSION)."
exit 1
fi
echo "Cargo.toml version matches the release tag."
build-and-push:
name: Build and Push
needs: check-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64, linux/arm64, linux/arm
push: true
tags: |
firstbatch/dkn-compute-node:latest
firstbatch/dkn-compute-node:${{ needs.check-release.outputs.image_tag }}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dkn-compute"
version = "0.3.1"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand Down

0 comments on commit 1d334d0

Please sign in to comment.