| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- name: Tag, Release and Docker Build & Push
- #on:
- # push:
- # branches:
- # - master
- on:
- workflow_dispatch:
- permissions:
- packages: write
- contents: write
- env:
- REPOSITORY: ${{ github.repository }}
- jobs:
- setup:
- name: Setup
- runs-on: ubuntu-latest
- outputs:
- repository: ${{ steps.vars.outputs.GITHUB_PROJECT_NAME }}
- steps:
- - name: Set lowercase repository
- id: vars
- run: echo "GITHUB_PROJECT_NAME=$(echo '${{ env.REPOSITORY }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- build:
- name: Build Images
- runs-on: ubuntu-latest
- needs: setup
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- - name: Setup Taskfile
- uses: pnorton5432/setup-task@v1
- with:
- task-version: 3.40.1
- - name: Build Docker images
- run: task actions:build-${{ github.sha }}
- env:
- GITHUB_PROJECT_NAME: ${{ needs.setup.outputs.repository }}
- - name: Upload Docker images artifacts
- uses: actions/upload-artifact@v4
- with:
- name: docker-images-${{ github.sha }}
- path: ./${{ github.sha }}
- retention-days: 1
- overwrite: true
- tag:
- name: Create Tag
- runs-on: ubuntu-latest
- needs: build
- outputs:
- tag: ${{ steps.tag.outputs.new_tag }}
- changelog: ${{ steps.tag.outputs.changelog }}
- steps:
- - uses: actions/checkout@v4
- - name: Bump version and push tag
- id: tag
- uses: mathieudutour/github-tag-action@v6.2
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- release:
- name: Publish Release
- runs-on: ubuntu-latest
- needs: tag
- outputs:
- tag: ${{ needs.tag.outputs.tag }}
- steps:
- - uses: actions/checkout@v4
- - name: Create a GitHub release
- uses: ncipollo/release-action@v1
- with:
- tag: ${{ needs.tag.outputs.tag }}
- name: Release ${{ needs.tag.outputs.tag }}
- body: ${{ needs.tag.outputs.changelog }}
- push:
- name: Push Images
- runs-on: ubuntu-latest
- needs:
- - setup
- - release
- outputs:
- tag: ${{ needs.release.outputs.tag }}
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- - name: Log in to GitHub Container Registry
- uses: docker/login-action@v2
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - name: Setup Taskfile
- uses: pnorton5432/setup-task@v1
- with:
- task-version: 3.40.1
- - name: Download Docker images artifacts
- uses: actions/download-artifact@v5
- with:
- name: docker-images-${{ github.sha }}
- path: ./${{ github.sha }}
- - name: Load Docker images
- run: task actions:load-${{ github.sha }}
- env:
- GITHUB_PROJECT_NAME: ${{ needs.setup.outputs.repository }}
- - name: Tag Docker images
- run: task actions:tag-${{ needs.release.outputs.tag }}
- env:
- GITHUB_PROJECT_NAME: ${{ needs.setup.outputs.repository }}
- - name: Push Docker images
- run: task actions:push-${{ needs.release.outputs.tag }}
- env:
- GITHUB_PROJECT_NAME: ${{ needs.setup.outputs.repository }}
- deploy:
- name: Deploy In Production
- runs-on: ubuntu-latest
- needs:
- - push
- steps:
- - uses: appleboy/ssh-action@v1.2.0
- with:
- host: ${{ secrets.HOST }}
- username: ${{ secrets.USERNAME }}
- key: ${{ secrets.KEY }}
- port: 22
- script: |
- # cd /opt/production
- task update-tag-${{ needs.push.outputs.tag }}
- task deploy
|