ci: deploy to staging hetzner #20
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: Next Application Build, Push, and Deploy | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "support-pali-v1-backward-compatibility" | ||
workflow_dispatch: # Manual trigger | ||
jobs: | ||
docker: | ||
permissions: | ||
contents: read | ||
packages: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/syscoin/syscoin-bridge | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Save metadata | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: metadata | ||
path: metadata.json | ||
deploy-staging-hetzner: | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
needs: docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download metadata | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: metadata | ||
path: ./metadata | ||
- name: Read Metadata | ||
id: read-metadata | ||
run: | | ||
cd metadata | ||
meta=$(cat metadata.json) | ||
echo "::set-output name=tags::$(echo "$meta" | jq -r '.target["docker-metadata-action"].tags | join(",")')" | ||
shell: bash | ||
- name: Deploy Frontend Service | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HETZNER_STAGING_HOST }} | ||
username: root | ||
key: ${{ secrets.HETZNER_SSH_KEY }} | ||
script: | | ||
Check failure on line 83 in .github/workflows/ghcr.yaml GitHub Actions / Next Application Build, Push, and DeployInvalid workflow file
|
||
export FRONTEND_IMAGE="${{ steps.read-metadata.outputs.tags | split(',')[0] }}" | ||
cd /root/bridge | ||
docker-compose pull frontend | ||
docker-compose up -d frontend |