Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: missing server host #300

Closed
miguelbernadi opened this issue Mar 3, 2024 · 6 comments
Closed

Error: missing server host #300

miguelbernadi opened this issue Mar 3, 2024 · 6 comments

Comments

@miguelbernadi
Copy link

I'm consistently getting this error in one workflow, while in another repo it works without issue. The repo where it works is a public repo, while the one where it fails is a private one.

The failing action is:

name: Production-CD

on:
  workflow_dispatch:
  push:
    tags:
      - 'v*'

# We ned `contents` to interact with release
permissions:
  contents: write

jobs:
  draft-release:
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
      id: ${{ steps.create_release.outputs.id }}
    steps:
    - name: draft-release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ github.token }}
      with:
        draft: true
        prerelease: false
        release_name: ${{ github.ref }}
        tag_name: ${{ github.ref }}

  bundle-client:
    runs-on: ubuntu-latest
    needs: [draft-release]
    defaults:
      run:
        working-directory: client

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: cache node_modules
        id: cache-node-modules
        uses: actions/cache@v4
        with:
          path: '**/node_modules'
          key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

      - name: Use Node.js 16.8
        uses: actions/setup-node@v4
        with:
          node-version: 16.8

      - name: install dependencies
        if: steps.cache-node-modules.outputs.cache-hit != 'true'
        run: npm ci

      - name: build FE
        run: npm run build

      - run: tar czf crisolAdmin-assets.tar.gz -C build/ .

      - name: upload artifacts
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.draft-release.outputs.upload_url }}
          asset_path: ./client/crisolAdmin-assets.tar.gz
          asset_name: crisolAdmin-assets.tar.gz
          asset_content_type: application/gzip

  bundle-server:
    runs-on: ubuntu-latest
    needs: [draft-release]
    defaults:
      run:
        working-directory: server
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Use Go 1.18
        uses: actions/setup-go@v4
        with:
          go-version: '^1.18.0'
          cache-dependency-path: server/go.sum

      - run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -ldflags="-X main.Commit=$(git rev-parse HEAD)" -o crisolAdmin

      - name: upload artifacts
        uses: actions/upload-release-asset@v1.0.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.draft-release.outputs.upload_url }}
          asset_path: ./server/crisolAdmin
          asset_name: crisolAdmin
          asset_content_type: application/binary

  publish-release:
    runs-on: ubuntu-latest
    needs:
      - draft-release
      - bundle-client
      - bundle-server
    steps:
      - uses: eregon/publish-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          release_id: ${{ needs.draft-release.outputs.id }}

  deploy:
    runs-on: ubuntu-latest
    needs:
      - publish-release
    permissions:
      actions: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true
    steps:
      - name: 🚀 Deploy website
        uses: appleboy/ssh-action@v1.0.3
        env:
         TAG: ${{ github.ref_name }}
        with:
          host: ${{ env.DEPLOY_HOST }}
          username: ${{ secrets.DEPLOY_USERNAME }}
          key: ${{ secrets.CRISOL_ADMIN_DEPLOY_PRIVATE_KEY }}
          port: ${{ secrets.DEPLOY_PORT }}
          command_timeout: 20m
          script: TAG=$TAG ./deploy-tag.sh

Any ideas on what may be the issue or how to debug it?

@appleboy
Copy link
Owner

appleboy commented Mar 5, 2024

What is your ${{ env.DEPLOY_HOST }} value?

image

@ariwijayaikd
Copy link

What is your ${{ env.DEPLOY_HOST }} value?

image

I have same issue, the value was variable, everything was normal until yesterday
image
image

@ariwijayaikd
Copy link

I just change the runner using github action runner in private vm (internal network) and it work

@appleboy
Copy link
Owner

appleboy commented Mar 5, 2024

@ariwijayaikd OK. I think it is a firewall issue. Thanks for your feedback

@miguelbernadi
Copy link
Author

The contents of ${{ env.DEPLOY_HOST }} were the DNS domain I was targeting. I hardcoded it instead of using a variable, and now it works. I also had to change the secrets I was using as I discovered organization secrets are not used in actions in our current paying tier. I suspect it may also complain about the host when the key is empty, but I cannot confirm it.

As I managed to solve it by avoiding variables and using repository secrets, I no longer have an issue, but error messages may be misleading.

@appleboy
Copy link
Owner

@miguelbernadi Thanks for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants