feat: Update backend workflow and .gitignore file #1
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 Push Backend with GitHub Actions | ||
on: | ||
workflow_call: | ||
secrets: | ||
DOCKER_USERNAME: | ||
required: true | ||
DOCKER_PASSWORD: | ||
required: true | ||
jobs: | ||
build: | ||
name: Build Backend | ||
runs-on: [self-hosted] | ||
outputs: | ||
version: "${{ steps.version.outputs.version }}" | ||
env: | ||
CARGO_INCREMENTAL: 0 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Print Event | ||
run: | | ||
echo "Event Name: ${{ github.event_name }}" | ||
echo "Repository: ${{ github.repository }}" | ||
echo "SHA: ${{ github.sha }}" | ||
echo "Ref: ${{ github.ref }}" | ||
echo "Action: ${{ github.action }}" | ||
echo "Actor: ${{ github.actor }}" | ||
echo "Workflow Run ID: ${{ github.run_id }}" | ||
echo "Head Repository: ${{ github.head_repository }}" | ||
echo "Base Repository: ${{ github.base_repository }}" | ||
- name: Get version | ||
id: version | ||
run: | | ||
if [[ -n "$GITHUB_REF" && "$GITHUB_REF" == "refs/tags/"* ]]; then | ||
echo "tag version" | ||
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}" | ||
else | ||
echo "commit version" | ||
echo "::set-output name=version::${{ github.sha }}" | ||
fi | ||
- name: Set Basic System | ||
run: | | ||
apt update \ | ||
&& apt install -y curl gcc musl-dev openssl libssl-dev pkg-config cmake | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
env: | ||
SCCACHE_GHA_ENABLED: "true" | ||
RUSTC_WRAPPER: "sccache" | ||
- name: Install latest nightly | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
- run: | | ||
cargo build --release \ | ||
&& ls -lh | ||
- name: Docker Login | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and Push GitDataOs | ||
uses: docker/build-push-action@v4 | ||
with: | ||
tags: | | ||
gitdatateam/gitdataos:${{ steps.version.outputs.version }} | ||
gitdatateam/gitdataos:latest | ||
push: true | ||
cache-from: type=gha | ||
file: ./Dockerfile | ||
cache-to: type=gha,mode=max | ||
platforms: linux/amd64 | ||
context: ${{ github.workspace }} |