Build Docker and Deploy #12
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 Docker and Deploy | |
| on: | |
| [workflow_dispatch] | |
| jobs: | |
| build_publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from Cargo.toml | |
| id: get_version | |
| run: | | |
| version=$(grep '^version =' Cargo.toml | head -1 | sed -E "s/version = \"(.*)\"/\1/") | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Build Docker image with both tags | |
| run: | | |
| docker build . -t ghcr.io/timhillier/rustbot:latest -t ghcr.io/timhillier/rustbot:${{ steps.get_version.outputs.version }} | |
| - name: Push Docker images | |
| run: | | |
| docker push ghcr.io/timhillier/rustbot:latest | |
| docker push ghcr.io/timhillier/rustbot:${{ steps.get_version.outputs.version }} |