File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build and Push Docker image on Release
2+
3+ on :
4+ workflow_run :
5+ # workflows: ["Create Release"]
6+ # types:
7+ # - completed
8+
9+ jobs :
10+ build :
11+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+
18+ - name : Log in to Docker Hub
19+ run : echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
20+
21+ - name : Get repository name
22+ id : repo_name
23+ run : echo "REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT
24+
25+ - name : Get latest release tag
26+ id : get_tag
27+ run : |
28+ TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
29+ echo "TAG=$TAG" >> $GITHUB_OUTPUT
30+
31+ - name : Build Docker image
32+ run : |
33+ docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:latest \
34+ -t ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.get_tag.outputs.TAG }} .
35+
36+ - name : Push Docker image
37+ run : |
38+ docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:latest
39+ docker push ${{ secrets.DOCKER_USERNAME }}/${{ steps.repo_name.outputs.REPO_NAME }}:${{ steps.get_tag.outputs.TAG }}
You can’t perform that action at this time.
0 commit comments