Skip to content

Add new authorization type. #51

Add new authorization type.

Add new authorization type. #51

Workflow file for this run

name: Test, build and deploy
on:
push:
branches:
- main
workflow_dispatch:
env:
IMAGE: ghcr.io/${{ github.repository }}
#PLATFORMS: linux/amd64,linux/arm64
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Start containerized environment
run: make
- name: Set up dependencies
run: make deps
- name: Run linter
run: make lint
- name: Run tests
run: make test
- name: Stop containerized environment
continue-on-error: true
run: make down
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
TAG: ${{ steps.metadata.outputs.TAG }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up metadata
id: metadata
run: |
TAG="${GITHUB_SHA::8}"
if [[ "${GITHUB_REF}" == "refs/tags/*" ]]; then
TAG="${GITHUB_REF#refs/tags/v}"
fi
echo "TAG=${TAG}" >> "${GITHUB_OUTPUT}"
#- name: Set up QEMU
# uses: docker/[email protected]
# with:
# platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log into image registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/[email protected]
with:
context: .
target: runtime
#platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ env.IMAGE }}:${{ steps.metadata.outputs.TAG }},${{ env.IMAGE }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs:
- test
- build
steps:
- name: Log into image registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract binary
run: |
ID=$(docker create ${{ env.IMAGE }}:${{needs.build.outputs.TAG}} --entrypoint 'sleep infinity')
docker cp "${ID}:/usr/local/bin/bin" ./app
docker rm --volumes "${ID}"
- name: Set up SSH
uses: shimataro/[email protected]
with:
name: id_ed25519
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Deploy
run: |
scp -P 22001 ./app caddy@${{ secrets.WEB_HOST }}:/srv/avptp/brain
ssh caddy@${{ secrets.WEB_HOST }} -p 22001 sudo systemctl restart avptp-brain