# README
Rex
Redeploy docker compose containers after git push
Installing the server:
This will install Rex's server which will allow deploying your app
- You can use the latest binary release in the releases
- Or if that doesn't work, compile it yourself using
go build -ldflags="-w -s"
- Set the environmental variables as showm in the
.env.example
- Either use flags when running the server, or set the environmental variable manually.
- Values' are taken from flags, if it doesn't exist it uses the corresponding environmental variable.
Flag | Env var | Description |
---|---|---|
port | REX_PORT_NUMBER | Give me a port number. (default: 7567 ) |
rex-key | REX_AUTH_KEY | Give me a secure key to use the GitHub action with |
repos-dir | REX_REPOS_DIR | Give me a proper directory path where your GitHub repos are stored in |
allowed-origins | REX_ALLOWED_ORIGINS | give me a list of allowed origins |
github-username | REX_GITHUB_USERNAME | Give me your GitHub username so I can pull repos' changes |
github-token | REX_GITHUB_TOKEN | Give me your GitHub token so I can pull repos' changes |
- Install the systemd service, since I haven't figured out how to make this fully work in docker :(
# /etc/systemd/system/rex.service
[Unit]
Description=Rex
[Service]
Type=simple
User=yourusername # REMOVE THIS COMMENT; so that git will work, and the other docker stuff
EnvironmentFile=/path/to/rex/.env_file # REMOVE THIS COMMENT; let systemd handle parsing the environmental variables
WorkingDirectory=/path/to/rex/ # REMOVE THIS COMMENT; they must be in the same directory, otherwise it won't work :)
ExecStart=/path/to/rex/binary
Restart=always
[Install]
WantedBy=multi-user.target
5. Reload systemd's daemons and start the server
sudo systemctl daemon-reload
sudo systemctl enable --now rex
Adding the GitHub action
This where the fun begins.
- Add a secret to your GitHub Repo called
REX_KEY
with the same value that you've set on the server- You can add the server url as a secret as well if you prefer to :)
- Create the GitHub action under
.github/workflows/rex-build.yml
jobs:
rex-deploy:
runs-on: ubuntu-latest
steps:
- name: rex-7567-e27
uses: mbaraa/[email protected]
with:
server-url: example.com
token: ${{ secrets.REX_KEY }}
repo-name: repoName
# commit-sha is optional :)
commit-sha: ${{ github.sha }}
# repo-tag is optional :)
repo-tag: ${{ github.ref }}
- Do a push and see the magic happen