forked from kuafuai/DevOpsGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(run): support docker build and run
- Loading branch information
Showing
5 changed files
with
103 additions
and
31 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,40 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "master" branch | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
|
||
# Runs a set of commands using the runners shell | ||
- name: Get pwd | ||
run: | | ||
pwd | ||
ls -alh | ||
- name: Run Docker Build Script | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
DOCKER_REPO: ${{ secrets.DOCKERHUB_REPO }} | ||
run: | | ||
chmod +x build.sh | ||
./build.sh |
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
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,20 @@ | ||
#!/bin/bash | ||
|
||
# Get the current commit SHA | ||
COMMIT_SHA=$(git rev-parse HEAD) | ||
|
||
# Get the current date in the format YYYYMMDD | ||
CURRENT_DATE=$(date +%Y%m%d) | ||
|
||
# Construct the new tag | ||
NEW_TAG="${CURRENT_DATE}-${COMMIT_SHA:0:7}" | ||
|
||
# Build the Docker image with the new tag | ||
docker build -t "${DOCKER_REPO}:${NEW_TAG}" -t "${DOCKER_REPO}:latest" -f Dockerfile . | ||
|
||
# Login to Docker Hub | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
|
||
# Push the Docker image with the new tag | ||
docker push "${DOCKER_REPO}:${NEW_TAG}" | ||
docker push "${DOCKER_REPO}:latest" |
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
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