Build (and deploy) #1722
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: Build (and deploy) | |
on: | |
push: | |
branches: | |
master | |
# run a minute past midnight (UTC), every day | |
schedule: | |
- cron: '01 00 * * *' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- name: Setup go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.15' | |
- name: Build | |
run: | | |
make fruktsam | |
./fruktsam | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
deploy: | |
runs-on: ubuntu-20.04 | |
if: (github.event_name == 'schedule') || (github.event_name == 'workflow_dispatch') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: true | |
- name: Setup go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.15' | |
- name: Install ssh | |
shell: bash | |
run: | | |
sudo apt-get update | |
sudo apt-get --no-install-recommends --no-install-suggests install openssh-client | |
- name: Fetch image cache | |
shell: bash | |
run: | | |
mkdir -p ./dist/images | |
cd ./dist/images | |
umask 077; echo "$PK" >/tmp/pk | |
echo "-get *.jpg" | sftp -b - -i /tmp/pk -o StrictHostKeyChecking=no sftp://[email protected]:55666/fruktsam/images/ | |
rm -f /tmp/pk | |
env: | |
PK: ${{ secrets.FRUKT_PRIVATEKEY }} | |
- name: Build | |
run: | | |
make fruktsam | |
./fruktsam | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
- name: Commit reversecache | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Update reversecache (fruktrobot)" | |
branch: master | |
file_pattern: reversecache | |
commit_user_name: 'fruktrobot' | |
commit_user_email: '<>' | |
- name: Deploy | |
shell: bash | |
run: | | |
cd ./dist | |
chmod -R go+rX . | |
umask 077; echo "$PK" >/tmp/pk | |
echo "put -Rp ." | sftp -b - -i /tmp/pk -o StrictHostKeyChecking=no sftp://[email protected]:55666/fruktsam/ | |
rm -f /tmp/pk | |
env: | |
PK: ${{ secrets.FRUKT_PRIVATEKEY }} |