Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Added GitHub Workflow publishing container images (#6433)
NyanKiyoshib871ef40e3b2
diff --git a/.circleci/config.yml b/.circleci/config.ymldeleted file mode 100644index 9b1ef86573..0000000000--- a/.circleci/config.yml+++ /dev/null@@ -1,59 +0,0 @@-version: 2-jobs:- build:- working_directory: /app- docker:- - image: docker:17.09.0-ce-git- steps:- - checkout- - setup_remote_docker:- docker_layer_caching: true- - run:- name: Set version- command: |- export SALEOR_VERSION=$(git rev-parse --short HEAD)- if [ -n "$CIRCLE_TAG" ]; then- export SALEOR_VERSION=$(git describe --tags)- fi- sed -i.bak "s#'dev'#'$SALEOR_VERSION'#" saleor/__init__.py- - run:- name: Build application Docker image- command: |- docker build \- --build-arg STATIC_URL=$STATIC_URL \- -t mirumee/saleor:latest .- - run:- name: Run tests- command: |- docker run -d --name db -e POSTGRES_USER=saleor -e POSTGRES_PASSWORD=saleor postgres:12.2-alpine- docker run --network container:db --rm -e DATABASE_URL mirumee/saleor:latest pytest- environment:- DATABASE_URL: postgres://saleor:saleor@localhost:5432/saleor- - deploy:- name: Push Docker image- command: |- docker login -u $DOCKERCLOUD_USER -p $DOCKERCLOUD_PASS- docker tag mirumee/saleor:latest mirumee/saleor:$CIRCLE_SHA1- docker push mirumee/saleor:$CIRCLE_SHA1- docker push mirumee/saleor:latest- - run:- name: Deploy saleor-demo- command: |- if [ -n "$CIRCLE_TAG" ]; then- apk add --upgrade --no-cache curl libcurl- sh ./scripts/push_static.sh- curl -u $DEMO_DEPLOY_KEY: \- -d build_parameters[CIRCLE_JOB]=deploy \- https://circleci.com/api/v1.1/project/github/mirumee/saleor-demo/tree/master- fi--workflows:- version: 2- build-deploy:- jobs:- - build:- filters:- branches:- only: master- tags:- only: /demo.*/diff --git a/.github/workflows/publish-containers.rst b/.github/workflows/publish-containers.rstnew file mode 100644index 0000000000..7921338e0c--- /dev/null+++ b/.github/workflows/publish-containers.rst@@ -0,0 +1,21 @@+Tagging Process+---------------+++-----------------------------------+-----------------------------------------------------------------------++| Git Ref | Container Tags |++===================================+=======================================================================++| ``refs/tags/1.0.0`` | ghcr.io/mirumee/saleor:1.0.0 |+| | ghcr.io/mirumee/saleor:latest |++-----------------------------------+-----------------------------------------------------------------------++| ``refs/tags/1.0.0a1`` | ghcr.io/mirumee/saleor:1.0.0a1 |+| | ghcr.io/mirumee/saleor:snapshot |++-----------------------------------+-----------------------------------------------------------------------++| ``refs/tags/1.0.0rc1`` | ghcr.io/mirumee/saleor:1.0.0rc1 |+| | ghcr.io/mirumee/saleor:snapshot |++-----------------------------------+-----------------------------------------------------------------------++| ``refs/heads/master`` | docker.io/mirumee/saleor:master |+| | docker.io/mirumee/saleor:sha-8ccaf90855b4a4251659c382a86e7e58f173c4e3 |++-----------------------------------+-----------------------------------------------------------------------++| ``refs/heads/preview/my-feature`` | docker.io/mirumee/saleor:my-feature |+| | docker.io/mirumee/saleor:sha-d122141d318518e216fc0e5b657259de317318c5 |++-----------------------------------+-----------------------------------------------------------------------+diff --git a/.github/workflows/publish-containers.yml b/.github/workflows/publish-containers.ymlnew file mode 100644index 0000000000..2ab281c66c--- /dev/null+++ b/.github/workflows/publish-containers.yml@@ -0,0 +1,133 @@+name: Publish++on:+ push:+ tags:+ # Matches stable and pre-releases+ - "[0-9]+.[0-9]+.[0-9]+*"+ branches:+ - master+ - ci/*/*++jobs:+ docker:+ runs-on: ubuntu-latest+ steps:+ - name: Checkout+ uses: actions/checkout@v2++ # Outputs the name of the repository (owner/repo)+ - name: Build Image Name+ id: image+ run: |+ # The name of the owner and of the repository: owner/repository+ IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')+ echo ::set-output name=image_name::${IMAGE_NAME}++ # Outputs container tags for tagged pushes starting by 'v'+ # Pushes only to GitHub Container Repository (ghcr.io)+ #+ # Tags stable versions as :latest+ # Pre-releases, alphas, etc. as :snapshot+ - name: Prepare Image Tags from Git Tag+ id: tagged+ if: ${{ startsWith(github.ref, 'refs/tags/') }}+ run: |+ # Remove everything else than the tagged version+ VERSION=${GITHUB_REF#refs/tags/}++ # Tag as stable (:latest) if there is no letters in the version+ # Otherwise, tag as preview (:snapshot)+ if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Matches 1.0.0, 1.0.1, etc.+ NAMED_VERSION="latest"+ else+ # Matches 1.0.0a1, 1.0.0rc1, etc.+ NAMED_VERSION="snapshot"+ fi++ TAGS=$"\+ ghcr.io/${{ steps.image.outputs.image_name }}:${NAMED_VERSION},\+ ghcr.io/${{ steps.image.outputs.image_name }}:${VERSION}\+ "++ # Output the target tags+ echo "+ CONTAINER_TAGS=${TAGS}+ NAMED_VERSION=${NAMED_VERSION}" >> "${GITHUB_ENV}"++ # Outputs the containers tags for staging branches+ # Only publishes them onto Docker Hub+ - name: Prepare Tags for Staging+ id: staging+ if: ${{ startsWith(github.ref, 'refs/heads/') }}+ run: |+ # Version name is the branch name+ # Slashes are substitued by dashes+ NAMED_VERSION=$(echo ${GITHUB_REF#refs/heads/} | tr / -)+ SHA=${GITHUB_SHA}++ # Target Docker Hub with the SHA value+ # and branch name+ TAGS=$"\+ ${{ steps.image.outputs.image_name }}:${NAMED_VERSION},\+ ${{ steps.image.outputs.image_name }}:sha-${SHA}\+ "++ # Output the target tags+ echo "+ CONTAINER_TAGS=${TAGS}+ NAMED_VERSION=${NAMED_VERSION}" >> "${GITHUB_ENV}"++ - name: Set up QEMU+ uses: docker/setup-qemu-action@v1+ with:+ platforms: all++ - name: Set up Docker Buildx+ id: buildx+ uses: docker/setup-buildx-action@v1++ - name: Cache Docker layers+ uses: actions/cache@v2+ with:+ path: /tmp/.buildx-cache+ key: ${{ runner.os }}-buildx-${{ github.sha }}+ restore-keys: |+ ${{ runner.os }}-buildx-++ - name: Login to DockerHub+ if: ${{ startsWith(github.ref, 'refs/heads/') }}+ uses: docker/login-action@v1+ with:+ username: ${{ secrets.DOCKER_USERNAME }}+ password: ${{ secrets.DOCKER_PASSWORD }}++ - name: Login to GitHub Container Registry+ if: ${{ startsWith(github.ref, 'refs/tags/') }}+ uses: docker/login-action@v1+ with:+ registry: ghcr.io+ username: ${{ secrets.CR_USERNAME }}+ password: ${{ secrets.CR_PAT }}++ - name: Build and Push+ id: docker_build+ uses: docker/build-push-action@v2+ with:+ builder: ${{ steps.buildx.outputs.name }}+ context: ./+ platforms: linux/amd64+ push: ${{ github.event_name != 'pull_request' }}+ tags: ${{ env.CONTAINER_TAGS }}+ cache-from: type=local,src=/tmp/.buildx-cache+ cache-to: type=local,dest=/tmp/.buildx-cache+ build-args: |+ VERSION=${{ env.NAMED_VERSION }}+ COMMIT_ID=${{ github.sha }}++ - name: Image digest+ run: |+ echo $"\+ Digest: ${{ steps.docker_build.outputs.digest }}+ Tags: ${{ env.CONTAINER_TAGS }}"diff --git a/Dockerfile b/Dockerfileindex ca148ac972..29bf1e901e 100644--- a/Dockerfile+++ b/Dockerfile@@ -45,4 +45,18 @@ RUN SECRET_KEY=dummy STATIC_URL=${STATIC_URL} python3 manage.py collectstatic --EXPOSE 8000ENV PYTHONUNBUFFERED 1+ARG COMMIT_ID+ARG VERSION++LABEL org.opencontainers.image.title="mirumee/saleor" \+ org.opencontainers.image.description="\+A modular, high performance, headless e-commerce platform built with Python, \+GraphQL, Django, and ReactJS." \+ org.opencontainers.image.url="https://saleor.io/" \+ org.opencontainers.image.source="https://github.com/mirumee/saleor" \+ org.opencontainers.image.revision=$COMMIT_ID \+ org.opencontainers.image.version=$VERSION \+ org.opencontainers.image.authors="Mirumee Software (https://mirumee.com)" \+ org.opencontainers.image.licenses="BSD 3"+CMD ["gunicorn", "--bind", ":8000", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "saleor.asgi:application"]diff --git a/README.md b/README.mdindex c7184c76da..138c52459c 100644--- a/README.md+++ b/README.md@@ -30,9 +30,6 @@<br><div align="center">- <a href="https://circleci.com/gh/mirumee/saleor">- <img src="https://circleci.com/gh/mirumee/saleor.svg?style=svg" alt="Build status" />- </a><a href="http://codecov.io/github/mirumee/saleor?branch=master"><img src="http://codecov.io/github/mirumee/saleor/coverage.svg?branch=master" alt="Codecov" /></a>