Skip to content

Commit

Permalink
test get tag
Browse files Browse the repository at this point in the history
Signed-off-by: Aisuko <[email protected]>
  • Loading branch information
Aisuko committed Jul 1, 2024
1 parent fd5f44c commit 4291bba
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 15 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ jobs:
run: |
echo "SHORT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
echo $SHORT_HASH
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo $TAG
run: |
echo "${{ env.SHORT_HASH }}"
- name: Build Docker image
if: startsWith(github.ref, 'refs/tags/') != true && success()
uses: docker/build-push-action@v4
with:
context: .
push: false
platforms: ${{ matrix.config.platforms }}
tags: "${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${{ env.SHORT_HASH }}"
file: ${{ matrix.config.dockerfile }}
# - name: Build Docker image
# if: startsWith(github.ref, 'refs/tags/') != true && success()
# uses: docker/build-push-action@v4
# with:
# context: .
# push: false
# platforms: ${{ matrix.config.platforms }}
# tags: "${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${{ env.SHORT_HASH }}"
# file: ${{ matrix.config.dockerfile }}
# run: |
# docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_SHA::7} .
52 changes: 46 additions & 6 deletions .github/workflows/release_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,60 @@ jobs:
name: 'Releasing Image 🐳'
strategy:
matrix:
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
config:
- { dockerfile: "Dockerfile", platforms: "linux/amd64,linux/arm64" }
runs-on: ubuntu-latest
steps:
- name: Check repository
uses: actions/checkout@v4

- name: Login to Container Registry
uses: docker/login-action@v3
# if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success()
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

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

# https://github.com/jlumbroso/free-disk-space/tree/54081f138730dfa15788a46383842cd2f914a1be#example
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Get tag name
id: tag
shell: bash
run: |
echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
echo $TAG
- name: Release Docker image
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success()
run: |
docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//} .
docker push ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//}
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: ${{ matrix.config.platforms }}
tags: "${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${{ env.TAG }}"
file: ${{ matrix.config.dockerfile }}
# run: |
# docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//} .
# docker push ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//}

0 comments on commit 4291bba

Please sign in to comment.