Skip to content

Commit

Permalink
build: add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 committed Dec 13, 2022
1 parent 57d4b45 commit 678e11a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
50 changes: 39 additions & 11 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
name: Push Docker Images
name: Build and Push Docker Images

on:
push:
branches:
- master

tags:
- open-release/*
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v2

# Use the release name as the image tag if we're building an open release tag.
# Examples: if we're building 'open-release/maple.1', tag the image as 'maple.1'.
# Otherwise, we must be building from a push to master, so use 'latest'.
- name: Get tag name
id: get-tag-name
uses: actions/github-script@v5
with:
script: |
const releasePrefix = 'refs/tags/open-release/';
const tagName = context.ref.split(releasePrefix)[1] || 'latest';
console.log('Will use tag: ' + tagName);
return tagName;
result-encoding: string

- name: Build and push Dev Docker image
uses: docker/build-push-action@v1
with:
push: true
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
target: dev
repository: edxops/discovery-dev
tags: ${{ steps.get-tag-name.outputs.result }},${{ github.sha }}

- name: Build and Push docker image
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run : make docker_push
# The current priority is to get the devstack off of Ansible based Images. Once that is done, we can come back to this part to get
# suitable images for smaller prod environments.
# - name: Build and push prod Docker image
# uses: docker/build-push-action@v1
# with:
# push: true
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_PASSWORD }}
# target: prod
# repository: edxops/discovery-prod
# tags: ${{ steps.get-tag-name.outputs.result }},${{ github.sha }}
16 changes: 0 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,6 @@ docs:
check_keywords: ## Scan the Django models in all installed apps in this project for restricted field names
python manage.py check_reserved_keywords --override_file db_keyword_overrides.yml

docker_build:
docker build . -f Dockerfile --target app -t openedx/discovery
docker build . -f Dockerfile --target newrelic -t openedx/discovery:latest-newrelic

docker_tag: docker_build
docker tag openedx/discovery openedx/discovery:${GITHUB_SHA}
docker tag openedx/discovery:latest-newrelic openedx/discovery:${GITHUB_SHA}-newrelic

docker_auth:
echo "$$DOCKERHUB_PASSWORD" | docker login -u "$$DOCKERHUB_USERNAME" --password-stdin

docker_push: docker_tag docker_auth ## push to docker hub
docker push 'openedx/discovery:latest'
docker push "openedx/discovery:${GITHUB_SHA}"
docker push 'openedx/discovery:latest-newrelic'
docker push "openedx/discovery:${GITHUB_SHA}-newrelic"

install_transifex_client: ## Install the Transifex client
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
Expand Down

0 comments on commit 678e11a

Please sign in to comment.