-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from firstbatchxyz/fco/ci
added ci for docker build n push
- Loading branch information
Showing
4 changed files
with
122 additions
and
2 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,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 }} |
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,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 }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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