Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Set up CI/CD with ghcr.io (#332)
Madison Swain-Bowden8de8d7034bbf
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlnew file mode 100644index 000000000..5afd00e03--- /dev/null+++ b/.github/workflows/ci_cd.yml@@ -0,0 +1,115 @@+name: CI + CD+on:+ pull_request:+ branches:+ - main+ push:+ branches:+ - main+ release:+ types:+ - published+ workflow_dispatch:++jobs:+ lint:+ name: Lint+ runs-on: ubuntu-latest+ steps:+ - name: Checkout repository+ uses: actions/checkout@v2+ - uses: extractions/setup-just@v1+ - name: Setup Python+ uses: actions/setup-python@v2+ with:+ python-version: "3.9"+ - name: Cache pre-commit envs+ uses: actions/cache@v2+ with:+ path: ~/.cache/pre-commit+ key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}+ - name: Run pre-commit to lint files+ run: |+ pip install pre-commit+ just lint++ build-images:+ name: Build image+ runs-on: ubuntu-latest+ steps:+ - name: Checkout repository+ uses: actions/checkout@v2++ - name: Setup Docker Buildx+ uses: docker/setup-buildx-action@v1+ with:+ install: true++ - name: Build image+ uses: docker/build-push-action@v2+ with:+ file: docker/airflow/Dockerfile+ push: false+ tags: openverse-catalog+ cache-from: type=gha,scope=catalog+ cache-to: type=gha,scope=catalog+ outputs: type=docker,dest=/tmp/catalog.tar++ - name: Upload image+ uses: actions/upload-artifact@v2+ with:+ name: catalog+ path: /tmp/catalog.tar++ test:+ name: Run tests+ runs-on: ubuntu-latest+ needs:+ - lint+ - build-images+ steps:+ - uses: actions/checkout@v2+ - uses: extractions/setup-just@v1++ - name: Change permissions for Docker steps+ run: chmod -R 777 openverse_catalog/ tests/++ - name: Test+ # Randomize test order to suss out any unseen dependencies+ run: |+ just build+ just test --random-order++ push:+ name: Publish Docker images+ runs-on: ubuntu-latest+ if: github.event_name == 'release' && github.event.action == 'published'+ needs:+ - test+ permissions:+ packages: write+ contents: read+ steps:+ - name: Log in to GitHub Docker Registry+ uses: docker/login-action@v1+ with:+ registry: https://ghcr.io+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Download image+ uses: actions/download-artifact@v2+ with:+ name: catalog+ path: /tmp++ - name: Load and tag image+ run: |+ docker load --input /tmp/catalog.tar+ docker tag openverse-catalog \+ ghcr.io/wordpress/openverse-catalog:latest+ docker tag openverse-catalog \+ ghcr.io/wordpress/openverse-catalog:${{ github.sha }}+ docker tag openverse-catalog \+ ghcr.io/wordpress/openverse-catalog:${{ github.ref_name }}+ docker push --all-tags ghcr.io/wordpress/openverse-catalogdiff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymldeleted file mode 100644index 35b91fda9..000000000--- a/.github/workflows/lint.yml+++ /dev/null@@ -1,27 +0,0 @@-name: linting-and-formatting--on:- push:- branches:- - main- paths:- - '**.py'- pull_request:- paths:- - '**.py'--jobs:- build:- runs-on: ubuntu-latest-- steps:- - uses: actions/checkout@v1- - uses: extractions/setup-just@v1- - name: Set up Python 3.9- uses: actions/setup-python@v1- with:- python-version: 3.9- - name: Lint- run: |- pip install pre-commit- just lintdiff --git a/.github/workflows/push_pull_request_test.yml b/.github/workflows/push_pull_request_test.ymldeleted file mode 100644index f74cc8597..000000000--- a/.github/workflows/push_pull_request_test.yml+++ /dev/null@@ -1,20 +0,0 @@-name: Automated testing workflow--on:- push:- branches:- - main- pull_request:--jobs:- test:- runs-on: ubuntu-latest-- steps:- - uses: actions/checkout@v2- - uses: extractions/setup-just@v1- - name: Change permissions for Docker steps- run: chmod -R 777 openverse_catalog/ tests/- - name: Test- # Randomize test order to suss out any unseen dependencies- run: just test --random-orderdiff --git a/README.md b/README.mdindex ac1bef734..edb604f62 100644--- a/README.md+++ b/README.md@@ -258,6 +258,9 @@ openverse-catalog└── * # Documentation, configuration files, and project requirements```+## Publishing++The docker image for the catalog (Airflow) is published to ghcr.io/WordPress/openverse-catalog.## Contributingdiff --git a/docker-compose.yml b/docker-compose.ymlindex 7e094d058..7cf975e3b 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -6,6 +6,7 @@ services:build:context: .dockerfile: docker/airflow/Dockerfile+ image: openverse-catalogenv_file: .envrestart: alwaysports: