[Add] github workflow template for push to docker #1
This file contains hidden or 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
| name: Build and Push Docker image on Release | ||
|
Check failure on line 1 in .github/workflows/docker-push.yml
|
||
| on: | ||
| workflow_run: | ||
| # workflows: ["Create Release"] | ||
| # types: | ||
| # - completed | ||
| jobs: | ||
| build: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Log in to Docker Hub | ||
| run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
| - name: Get repository name | ||
| id: repo_name | ||
| run: echo "REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT | ||
| - name: Get latest release tag | ||
| id: get_tag | ||
| run: | | ||
| TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name) | ||
| echo "TAG=$TAG" >> $GITHUB_OUTPUT | ||
| - name: Build Docker image | ||
| run: | | ||
| docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:latest \ | ||
| -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.get_tag.outputs.TAG }} . | ||
| - name: Push Docker image | ||
| run: | | ||
| docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:latest | ||
| docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.get_tag.outputs.TAG }} | ||