-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: chenyufeifei <[email protected]>
- Loading branch information
1 parent
203bb18
commit 4d05f96
Showing
1 changed file
with
72 additions
and
0 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,72 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
push_image_to_registry: | ||
name: Push Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Get Version | ||
id: get_version | ||
run: | | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then | ||
VERSION=latest | ||
fi | ||
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | ||
- name: Get Git Revision | ||
id: vars | ||
shell: bash | ||
run: | | ||
echo "git_revision=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
- name: PrepareReg Names | ||
run: | | ||
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push to Registry | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
file: Dockerfile | ||
labels: |- | ||
org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
build-args: | | ||
GITVERSION=git-${{ steps.vars.outputs.git_revision }} | ||
VERSION=${{ steps.get_version.outputs.VERSION }} | ||
tags: | | ||
dragonflyoss/dragonfly-repository-agent:${{ steps.get_version.outputs.VERSION }} | ||
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ steps.get_version.outputs.VERSION }} | ||
push: | ||
true |