Update docker image #123
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 Engine | |
on: | |
push: | |
paths: | |
- 'engine/**' | |
- '.github/workflows/build.yaml' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: v3xlabs/v3x-property/engine | |
jobs: | |
deploy: | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
env: | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Configure sccache | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
with: | |
version: "v0.7.4" | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Cache Cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo build | |
uses: actions/cache@v3 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Run sccache-cache | |
uses: mozilla-actions/[email protected] | |
with: | |
version: "v0.7.4" | |
- name: Start postgres via docker-compose dev | |
working-directory: ./engine | |
run: docker compose -f ./compose.yaml up postgres -d | |
- name: Setup Env | |
working-directory: ./engine | |
run: cp .env.example .env | |
- name: Get Runner IP | |
id: get_ip | |
run: echo "RUNNER_IP=$(hostname -I | awk '{print $1}')" >> $GITHUB_ENV | |
- name: Migrate db | |
working-directory: ./engine | |
run: cargo install sqlx-cli --no-default-features --features native-tls,postgres && sqlx migrate run && cargo sqlx prepare | |
- name: Stop postgres via docker-compose dev | |
working-directory: ./engine | |
run: docker compose -f ./compose.yaml down | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build docker image using github actions | |
uses: docker/build-push-action@v6 | |
id: push | |
with: | |
context: ./engine | |
file: ./engine/.build/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |