2022-05-28 23:40:37 +00:00
|
|
|
# Build, test and push InvenTree docker image
|
|
|
|
# This workflow runs under any of the following conditions:
|
|
|
|
#
|
|
|
|
# - Push to the master branch
|
|
|
|
# - Publish release
|
|
|
|
#
|
|
|
|
# The following actions are performed:
|
|
|
|
#
|
|
|
|
# - Check that the version number matches the current branch or tag
|
|
|
|
# - Build the InvenTree docker image
|
|
|
|
# - Run suite of unit tests against the build image
|
|
|
|
# - Push the compiled, tested image to dockerhub
|
|
|
|
|
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
2022-08-14 22:20:03 +00:00
|
|
|
types: [ published ]
|
2022-05-28 23:40:37 +00:00
|
|
|
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
# Build the docker image
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2022-07-20 06:20:58 +00:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
2022-05-30 23:50:38 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2022-05-28 23:40:37 +00:00
|
|
|
steps:
|
|
|
|
- name: Check out repo
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
|
2022-05-28 23:40:37 +00:00
|
|
|
- name: Version Check
|
|
|
|
run: |
|
2022-06-06 22:57:51 +00:00
|
|
|
pip install requests
|
2022-05-30 23:50:38 +00:00
|
|
|
python3 ci/version_check.py
|
2022-05-28 23:40:37 +00:00
|
|
|
echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
|
|
echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV
|
2022-06-28 03:47:10 +00:00
|
|
|
- name: Build Docker Image
|
2022-07-26 21:50:54 +00:00
|
|
|
# Build the development docker image (using docker-compose.yml)
|
2022-05-28 23:40:37 +00:00
|
|
|
run: |
|
|
|
|
docker-compose build
|
2022-06-28 03:47:10 +00:00
|
|
|
- name: Run Unit Tests
|
|
|
|
run: |
|
2022-05-28 23:40:37 +00:00
|
|
|
docker-compose run inventree-dev-server invoke update
|
2022-07-01 11:03:25 +00:00
|
|
|
docker-compose run inventree-dev-server invoke setup-dev
|
2022-05-28 23:40:37 +00:00
|
|
|
docker-compose up -d
|
|
|
|
docker-compose run inventree-dev-server invoke wait
|
|
|
|
docker-compose run inventree-dev-server invoke test
|
|
|
|
docker-compose down
|
2022-07-26 21:50:54 +00:00
|
|
|
- name: Check Data Directory
|
|
|
|
# The following file structure should have been created by the docker image
|
|
|
|
run: |
|
|
|
|
test -d data
|
|
|
|
test -d data/env
|
|
|
|
test -d data/pgdb
|
|
|
|
test -d data/media
|
|
|
|
test -d data/static
|
|
|
|
test -d data/plugins
|
|
|
|
test -f data/config.yaml
|
|
|
|
test -f data/plugins.txt
|
|
|
|
test -f data/secret_key.txt
|
2022-05-28 23:40:37 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # pin@v1
|
2022-05-28 23:40:37 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9 # pin@v1
|
2022-07-20 06:20:58 +00:00
|
|
|
- name: Set up cosign
|
2022-07-26 21:50:54 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: sigstore/cosign-installer@09a077b27eb1310dcfb21981bee195b30ce09de0 # pin@v2.5.0
|
2022-05-28 23:40:37 +00:00
|
|
|
- name: Login to Dockerhub
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # pin@v1
|
2022-05-28 23:40:37 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2022-07-20 06:20:58 +00:00
|
|
|
- name: Extract Docker metadata
|
2022-07-26 21:50:54 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-07-20 06:20:58 +00:00
|
|
|
id: meta
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # pin@v4.0.1
|
2022-07-20 08:32:18 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
inventree/inventree
|
2022-05-28 23:40:37 +00:00
|
|
|
- name: Build and Push
|
2022-07-20 06:20:58 +00:00
|
|
|
id: build-and-push
|
2022-05-28 23:40:37 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-08-14 22:20:03 +00:00
|
|
|
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # pin@v2
|
2022-05-28 23:40:37 +00:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2022-05-29 03:47:29 +00:00
|
|
|
push: true
|
2022-05-28 23:40:37 +00:00
|
|
|
target: production
|
2022-05-30 23:50:38 +00:00
|
|
|
tags: ${{ env.docker_tags }}
|
2022-05-31 04:26:35 +00:00
|
|
|
build-args: |
|
|
|
|
commit_hash=${{ env.git_commit_hash }}
|
|
|
|
commit_date=${{ env.git_commit_date }}
|
2022-07-20 06:20:58 +00:00
|
|
|
- name: Sign the published image
|
2022-07-26 21:50:54 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2022-07-20 06:20:58 +00:00
|
|
|
env:
|
|
|
|
COSIGN_EXPERIMENTAL: "true"
|
2022-08-14 22:20:03 +00:00
|
|
|
run: cosign sign ${{ steps.meta.outputs.tags }}@${{
|
|
|
|
steps.build-and-push.outputs.digest }}
|