CI #11
Workflow file for this run
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: CI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| Docker: | |
| description: 'Build and push to Docker Hub' | |
| default: false | |
| type: boolean | |
| Binary: | |
| description: 'Build binary' | |
| default: true | |
| type: boolean | |
| Version: | |
| description: 'Version for binary' | |
| required: true | |
| default: 'latest' | |
| type: string | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone main repository | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| if: ${{ github.event.inputs.Docker == 'true' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Install Docker Buildx | |
| if: ${{ github.event.inputs.Docker == 'true' }} | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| install: true | |
| - name: Build and push Docker images for amd64 and arm64 | |
| if: ${{ github.event.inputs.Docker == 'true' }} | |
| run: | | |
| # docker build -t lifailon/ssh-bot:latest . | |
| # docker push lifailon/ssh-bot:latest | |
| docker buildx build \ | |
| --platform \ | |
| linux/amd64,linux/arm64 \ | |
| -t lifailon/ssh-bot \ | |
| --push . | |
| continue-on-error: true | |
| - name: Install Go | |
| if: ${{ github.event.inputs.Binary == 'true' }} | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.23 | |
| - name: Build binaries | |
| if: ${{ github.event.inputs.Binary == 'true' }} | |
| run: | | |
| mkdir -p bin | |
| architectures=("amd64" "arm64") | |
| for arch in "${architectures[@]}"; do | |
| CGO_ENABLED=0 GOOS=windows GOARCH=$arch go build -o bin/ssh-bot-${{ github.event.inputs.Version }}-windows-$arch.exe main.go | |
| CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -o bin/ssh-bot-${{ github.event.inputs.Version }}-linux-$arch main.go | |
| # CGO_ENABLED=0 GOOS=darwin GOARCH=$arch go build -o bin/ssh-bot-${{ github.event.inputs.Version }}-darwin-$arch main.go | |
| done | |
| ls -lh bin | |
| mkdir -p bin/{ssh-bot-linux,ssh-bot-windows,ssh-bot-raspberry-pi} | |
| mv bin/ssh-bot-${{ github.event.inputs.Version }}-windows-amd64.exe bin/ssh-bot-windows/ssh-bot.exe | |
| cp ./.env.example bin/ssh-bot-windows/.env | |
| mv bin/ssh-bot-${{ github.event.inputs.Version }}-linux-amd64 bin/ssh-bot-linux/ssh-bot | |
| cp ./.env.example bin/ssh-bot-linux/.env | |
| mv bin/ssh-bot-${{ github.event.inputs.Version }}-linux-arm64 bin/ssh-bot-raspberry-pi/ssh-bot | |
| cp ./.env.example bin/ssh-bot-raspberry-pi/.env | |
| ls -lha bin/* | |
| tar -cvf bin/ssh-bot-windows.tar -C bin/ssh-bot-windows/ ssh-bot.exe .env | |
| tar -cvf bin/ssh-bot-linux.tar -C bin/ssh-bot-linux/ ssh-bot .env | |
| tar -cvf bin/ssh-bot-raspberry-pi.tar -C bin/ssh-bot-raspberry-pi/ ssh-bot .env | |
| - name: Upload binaries for Windows | |
| if: ${{ github.event.inputs.Binary == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ssh-bot-windows-${{ github.event.inputs.Version }} | |
| path: bin/ssh-bot-windows.tar | |
| - name: Upload binaries for Linux | |
| if: ${{ github.event.inputs.Binary == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ssh-bot-linux-${{ github.event.inputs.Version }} | |
| path: bin/ssh-bot-linux.tar | |
| - name: Upload binaries for Raspberry Pi | |
| if: ${{ github.event.inputs.Binary == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ssh-bot-raspberry-pi-${{ github.event.inputs.Version }} | |
| path: bin/ssh-bot-raspberry-pi.tar |