48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- Django
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
docker-ci:
|
|
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[ci]'))
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 40
|
|
env:
|
|
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
|
|
DJANGO_DEBUG: "False"
|
|
DJANGO_ALLOWED_HOSTS: "127.0.0.1,localhost"
|
|
IMAGE_NAME: achievement_inputing_ci
|
|
steps:
|
|
- name: Ensure source present
|
|
env:
|
|
SERVER: ${{ github.server_url }}
|
|
REPO: ${{ github.repository }}
|
|
REF: ${{ github.ref }}
|
|
SHA: ${{ github.sha }}
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
if [ -f "$GITHUB_WORKSPACE/Dockerfile" ]; then exit 0; fi
|
|
mkdir -p "$GITHUB_WORKSPACE"
|
|
cd "$GITHUB_WORKSPACE"
|
|
git init .
|
|
if [ -z "$TOKEN" ]; then
|
|
git fetch --depth=1 "$SERVER/$REPO.git" "$REF"
|
|
else
|
|
git -c http.extraHeader="Authorization: Bearer $TOKEN" fetch --depth=1 "$SERVER/$REPO.git" "$REF"
|
|
fi
|
|
git checkout FETCH_HEAD
|
|
- name: Build application image
|
|
run: |
|
|
docker build -t "$IMAGE_NAME" -f "$GITHUB_WORKSPACE/Dockerfile" "$GITHUB_WORKSPACE"
|
|
- name: Output image info
|
|
run: |
|
|
docker image inspect "$IMAGE_NAME" --format '{{.Id}} {{.Size}}'
|