Skip to content

ci: add write metadata #25

ci: add write metadata

ci: add write metadata #25

Workflow file for this run

name: Next Application Build, Push, and Deploy
on:
push:
branches:
- "main"
- "support-pali-v1-backward-compatibility"
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: Write metadata
run: "cp $DOCKER_METADATA_OUTPUT_BAKE_FILE metadata.json"
- name: Save metadata
uses: actions/upload-artifact@v4
with:
name: metadata
path: metadata.json
deploy-staging:
needs: docker
environment:
name: staging
permissions:
deployments: write
contents: read
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]
env:
IMAGE_TAG: ${{ steps.read-metadata.outputs.tags }}
with:
host: ${{ secrets.HETZNER_STAGING_HOST }}
username: root
key: ${{ secrets.HETZNER_SSH_KEY }}
script: |
export FRONTEND_IMAGE="$(echo ${{ env.IMAGE_TAG }} | cut -d ',' -f 2)"
cd /root/bridge
docker-compose pull frontend
docker-compose up -d frontend