ariandanim

ariandanim

Github Action not working, just stack in somewhere

Dear all,
Does my code workflow in yml below is correct for deploying into vps ?

name: Deployment Workflow
on:
  push:
    branches: [ main ]

jobs:
  job_one:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
    - name: testing myweb.com ssh connection
      uses: appleboy/ssh-action@master
      with:
        host: myweb.com
        username: root
        key: ${{ secrets.MYWEB_SECRET }}
        port: 22
        script: |
          cd /var/www/myweb.com
          git pull origin main
          mix deps.get --only prod
          export SECRET_KEY_BASE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
          export DATABASE_URL=ecto://postgres:password@localhost:5432/myweb_prod
          MIX_ENV=prod mix compile
          MIX_ENV=prod mix assets.deploy
          MIX_ENV=prod mix ecto.migrate
          MIX_ENV=prod mix release --overwrite
          _build/prod/rel/myweb/bin/myweb stop
          _build/prod/rel/myweb/bin/myweb daemon

SECRET_KEY_BASE i get in my server app when i try make generate that

Before push into my github to deploy into my server i make some steps below :
I try type in my server _build/prod/rel/myweb/bin/myweb start but showing error like below :
07:28:24.954 [info] Configuration :server was not enabled for MyappWeb.Endpoint, http/https services won't start

Why those appear?

Marked As Solved

LostKobrakai

LostKobrakai

Phoenix by default doesn’t start listening on a port. You need to configure it to enable that, e.g. using

config :myapp, MyAppWeb.Endpoint, server: true

This has nothing to do with github actions.

Generally there’s a few things to optimize here. Move the secrets out of the yml, they shouldn’t be in there. Let the github action build the release instead of doing the release building on the target server. That’ll also remove the need for the target server to have elixir and whatever you need for assets.deploy installed.

Also using …/myapp daemon is imo not a great long term solution. You’d want to start the release using the init system of your target os (most likely systemd on linux).

Also Liked

kokolegorille

kokolegorille

Another way is to use runtime.exs…

and run mix phx.gen.release, or set PHX_SERVER true before starting release

# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
# script that automatically sets the env var above.
if System.get_env("PHX_SERVER") do
  config :koko, KokoWeb.Endpoint, server: true
end

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New

We're in Beta

About us Mission Statement