forked from commune-ai/subspace
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tag docker image with branch name and git tags
- Loading branch information
1 parent
58e318e
commit beea080
Showing
2 changed files
with
48 additions
and
3 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
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,35 @@ | ||
name: Tag docker image with git tags | ||
|
||
on: | ||
push: | ||
tags: ["*"] | ||
|
||
env: | ||
image_base: ghcr.io/agicommies/subspace | ||
|
||
jobs: | ||
tag-docker-image: | ||
permissions: write-all | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- id: commit | ||
uses: prompt/actions-commit-hash@v3 | ||
|
||
- name: Docker Login | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checks if docker image is on registry | ||
env: | ||
image_of_commit: $image_base:${{ steps.commit.outputs.short }} | ||
run: | | ||
image_exists_check=$(docker manifest inspect "$image_of_commit" > /dev/null 2>&1; echo $?) | ||
if [ $image_exists_check -eq 0 ]; then | ||
echo "Image exists. Tagging with `${{ github.ref_name }}`" | ||
docker buildx imagetools create "$image_of_commit" --tag "$image_base:${{ github.ref_name }}" | ||
fi |