Skip to content

[Add] github workflow template for push to docker #1

[Add] github workflow template for push to docker

[Add] github workflow template for push to docker #1

Workflow file for this run

name: Build and Push Docker image on Release

Check failure on line 1 in .github/workflows/docker-push.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docker-push.yml

Invalid workflow file

`on.workflow_run` does not reference any workflows. See https://docs.github.com/actions/learn-github-actions/events-that-trigger-workflows#workflow_run for more information
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 }}