mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
aca58dedc0
- Add required "images" attribute - Ref: https://github.com/docker/metadata-action#images-input
98 lines
3.0 KiB
YAML
98 lines
3.0 KiB
YAML
# 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:
|
|
types: [published]
|
|
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
|
|
jobs:
|
|
|
|
# Build the docker image
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
steps:
|
|
- name: Check out repo
|
|
uses: actions/checkout@v2
|
|
- name: Version Check
|
|
run: |
|
|
pip install requests
|
|
python3 ci/version_check.py
|
|
echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
|
echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV
|
|
- name: Build Docker Image
|
|
run: |
|
|
docker-compose build
|
|
- name: Run Unit Tests
|
|
run: |
|
|
docker-compose run inventree-dev-server invoke update
|
|
docker-compose run inventree-dev-server invoke setup-dev
|
|
docker-compose up -d
|
|
docker-compose run inventree-dev-server invoke wait
|
|
docker-compose run inventree-dev-server invoke test
|
|
docker-compose down
|
|
- name: Set up QEMU
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/setup-qemu-action@v1
|
|
- name: Set up Docker Buildx
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Set up cosign
|
|
uses: sigstore/cosign-installer@48866aa521d8bf870604709cd43ec2f602d03ff2
|
|
- name: Login to Dockerhub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
|
|
with:
|
|
images: |
|
|
inventree/inventree
|
|
- name: Build and Push
|
|
id: build-and-push
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
target: production
|
|
tags: ${{ env.docker_tags }}
|
|
build-args: |
|
|
commit_hash=${{ env.git_commit_hash }}
|
|
commit_date=${{ env.git_commit_date }}
|
|
- name: Sign the published image
|
|
env:
|
|
COSIGN_EXPERIMENTAL: "true"
|
|
run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }}
|
|
- name: Push to Stable Branch
|
|
uses: ad-m/github-push-action@master
|
|
if: env.stable_release == 'true'
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: stable
|
|
force: true
|