Skip to content

Commit

Permalink
fix(ci/cd): Switch Docker images to ghcr.io
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Jun 6, 2024
1 parent b5046aa commit b64ffeb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.mypy*
.vscode
venv
49 changes: 34 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
name: Publish Docker image
name: Publish release

on:
push:
tags:
- '*'
- '[0-9]+.[0-9]+.[0-9]+'

env:
MM_NOTIFICATION_CHANNEL: 'bso-bot'

jobs:
build:
publish-ghcr:
name: Docker image
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 🏷️ Get Tag
id: version
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: 🔑 Login docker
run: docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}

- name: 🐋 Build docker image
run: make docker-build

- name: 🔑 Login docker
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}

- name: 📦 Push docker image
run: make docker-push

release:
name: Release new version
runs-on: ubuntu-latest
needs: publish-ghcr
steps:
- name: 🏁 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🏷️ Get tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: 📦 Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}

notify:
needs: build
needs: release
if: always()
runs-on: ubuntu-latest
steps:
- uses: dataesr/mm-notifier-action@v1
- uses: dataesr/mm-notifier-action@v1.1
with:
github_token: ${{ secrets.GITHUB_TOKEN}}
mattermost_webhook_url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
mattermost_channel: ${{ env.MM_NOTIFICATION_CHANNEL}}
github_token: ${{ secrets.GITHUB_TOKEN }}
mattermost_channel: ${{ env.MM_NOTIFICATION_CHANNEL }}
mattermost_webhook_url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
venv
.mypy*
.vscode
venv
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_IMAGE_NAME=dataesr/harvest-pubmed
DOCKER_IMAGE_NAME=ghcr.io/dataesr/harvest-pubmed
CURRENT_VERSION=$(shell cat pubmed/__init__.py | cut -d "'" -f 2)

docker-build:
Expand All @@ -8,8 +8,7 @@ docker-build:

docker-push:
@echo Pushing a new docker image
docker push $(DOCKER_IMAGE_NAME):$(CURRENT_VERSION)
docker push $(DOCKER_IMAGE_NAME):latest
docker push -a $(DOCKER_IMAGE_NAME)
@echo Docker image pushed

install:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# harvest-pubmed

![GitHub](https://img.shields.io/github/license/dataesr/harvest-pubmed)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/dataesr/harvest-pubmed)
![Build](https://github.com/dataesr/harvest-pubmed/actions/workflows/build.yml/badge.svg)

## Release
Expand Down

0 comments on commit b64ffeb

Please sign in to comment.