appleboy / ssh-action

GitHub Actions for executing remote ssh commands.
https://github.com/marketplace/actions/ssh-remote-commands
MIT License
4.84k stars 576 forks source link

ci: enhance GitHub Actions for IPv6 and flexibility #303

Closed appleboy closed 8 months ago

appleboy commented 8 months ago

fixed https://github.com/appleboy/ssh-action/issues/146 reference: https://github.com/actions/runner-images/issues/668

muckelba commented 8 months ago

Hey, this PR broke my pipeline: image

I have zero clue why changing the shebang from #!/bin/sh to #!/usr/bin/env bash should cause this error. I'm using ubuntu-latest for that job.

appleboy commented 8 months ago

@muckelba I will take it. Thanks for your report.

appleboy commented 8 months ago

@muckelba I try the ubuntu-latest os. It is working. Can you show all the configs?

muckelba commented 8 months ago
name: Create, publish and deploy a Docker image

on:
  push:
    branches:
      - main
      - develop

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to GHCR
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build Docker image
        uses: docker/build-push-action@v3
        with:
          context: .
          push: true
          tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}

  deploy:
    runs-on: ubuntu-latest
    needs: build-and-push-image

    steps:
      - name: SSH Deploy
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.SSHKEY }}
          script: |
            cd ${{ secrets.PATH }}_${{ github.ref_name }}
            echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
            docker compose pull && docker compose up -d

this is my whole config

appleboy commented 8 months ago

@muckelba move to https://github.com/appleboy/ssh-action/issues/306 for further discussion.