Build the emailformgateway http server #16
This file contains 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: Email_Form_Gateway_Build_Test_And_Deploy | ||
on: [push, pull_request] | ||
jobs: | ||
deploy: | ||
name: "Deploy to senpaid" | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download and install go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.0' | ||
- name: Print Go version | ||
run: go version | ||
- name: Run tests | ||
run: CGO_ENABLED=0 go test -skip=SendEmail github.com/owenwaller/emailformgateway/... | ||
- name: Build emailer test | ||
run: CGO_ENABLED=0 go test -c -o ./emailer.test -run=SendEmail github.com/owenwaller/emailformgateway/emailer | ||
- name: Build server test | ||
run: CGO_ENABLED=0 go test -c -o ./server.test -run=SendEmail github.com/owenwaller/emailformgateway/server | ||
- nane: Build emailformgateway server | ||
run: go build -o ./emailformgateway ./cmd/main.go | ||
- name: Listing | ||
run: 'ls -al' | ||
- name: Configure SSH | ||
run: | | ||
mkdir -p ~/.ssh/ | ||
echo "$SSH_KEY" > ~/.ssh/gophercoders.key | ||
chmod 600 ~/.ssh/gophercoders.key | ||
cat >>~/.ssh/config <<END | ||
Host gophercoders.com | ||
HostName $SSH_HOST | ||
User $SSH_USER | ||
Port $SSH_PORT | ||
IdentityFile ~/.ssh/gophercoders.key | ||
StrictHostKeyChecking no | ||
ProxyCommand openssl s_client -quiet -connect senpaid.com:$SSH_PORT -servername www.gophercoders.com | ||
END | ||
env: | ||
SSH_KEY: ${{ secrets.SENPAID_SERVER_SSH_KEY }} | ||
SSH_USER: ${{ secrets.SENPAID_SERVER_USERNAME }} | ||
SSH_HOST: ${{ secrets.SENPAID_SERVER_HOSTNAME }} | ||
SSH_PORT: ${{ secrets.SENPAID_SERVER_PORT }} | ||
- name: List public dir | ||
run: ssh gophercoders.com 'whoami; ls -l ~/' | ||
- name: Create env file | ||
run: | | ||
cat >> ./test_envs.sh <<END | ||
export TEST_CUSTOMER_TO_EMAIL_ADDRESS=$TEST_CUSTOMER_TO_EMAIL_ADDRESS | ||
export TEST_SYSTEM_TO_EMAIL_ADDRESS=$TEST_SYSTEM_TO_EMAIL_ADDRESS | ||
export TEST_CONFIG_FILE=$TEST_CONFIG_FILE | ||
END | ||
env: | ||
TEST_CUSTOMER_TO_EMAIL_ADDRESS: ${{ secrets.TEST_CUSTOMER_TO_EMAIL_ADDRESS }} | ||
TEST_SYSTEM_TO_EMAIL_ADDRESS: ${{ secrets.TEST_SYSTEM_TO_EMAIL_ADDRESS }} | ||
TEST_CONFIG_FILE: ${{ secrets.TEST_CONFIG_FILE }} | ||
- name: Copy files to server | ||
run: | | ||
scp ./emailformgateway ./test_envs.sh ./emailer.test ./server.test ./*.template ./gophercoders-config.toml $TEST_CONFIG_FILE.toml gophercoders.com: | ||
env: | ||
TEST_CONFIG_FILE: ${{ secrets.TEST_CONFIG_FILE }} | ||
- name: Run emailer.test test | ||
run: | | ||
ssh gophercoders.com 'source ./test_envs.sh; TEST_TEMPLATES_DIR=$PWD TEST_DOMAIN=gophercoders.com ./emailer.test' | ||
- name: Run server.test test | ||
run: | | ||
ssh gophercoders.com 'source ./test_envs.sh; TEST_TEMPLATES_DIR=$PWD TEST_DOMAIN=example.com ./server.test' | ||
- name: Delete ssh dir | ||
if: ${{ always() }} | ||
run: | | ||
rm -rf ~/.ssh | ||
rm ./test_envs.sh |