Skip to content

Merge pull request #630 from RNAcentral/release-24 #435

Merge pull request #630 from RNAcentral/release-24

Merge pull request #630 from RNAcentral/release-24 #435

Workflow file for this run

# This workflow will run the unit tests and build a new image on both Docker Hub and GitHub Packages.
# At least for now, the image will be created regardless of whether the tests are run successfully or not.
#
# References:
# - https://docs.github.com/en/actions/guides/building-and-testing-python
# - https://github.com/marketplace/actions/slack-notify
name: Building Docker containers
# Triggers the workflow on push or pull request events
on:
push:
paths-ignore:
- 'jenkins/**'
- 'kubernetes/**'
- 'nginx/**'
- 'openssl/**'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies and rename local_settings file
run: |
python -m pip install --upgrade pip
pip install -r rnacentral/requirements.txt
pip install -r rnacentral/requirements_dev.txt
mv rnacentral/rnacentral/unit_test_local_settings.py rnacentral/rnacentral/local_settings.py
- name: Run tests
run: |
python rnacentral/manage.py test apiv1
python rnacentral/manage.py test export
python rnacentral/manage.py test portal
python rnacentral/manage.py test sequence_search
initial-notification:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Initial notification
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_MESSAGE: 'Publishing images to Docker Hub and GitHub Packages'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true
push_image_to_dockerhub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: docker login
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Get branch name
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: docker build
if: env.BRANCH_NAME != ''
run: docker build -f Dockerfile -t rnacentral/rnacentral-webcode:${{ env.BRANCH_NAME }} .
- name: docker push
if: env.BRANCH_NAME != ''
run: docker push rnacentral/rnacentral-webcode:${{ env.BRANCH_NAME }}
push_image_to_github:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96
with:
images: ghcr.io/${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
final-notification:
runs-on: ubuntu-latest
needs: [push_image_to_dockerhub, push_image_to_github]
steps:
- uses: actions/checkout@v3
- name: Final notification
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_MESSAGE: 'New image pushed to Docker Hub and GitHub Packages'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true