Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Actions job for uploading container image to Harbor #368

Merged
merged 9 commits into from
May 30, 2022
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"
37 changes: 36 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ on:
workflow_dispatch:
pull_request:
push:
# TODO - Change this to main before merging k8s-deployment into main
branches:
- main
- k8s-deployment
jobs:
tests:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -329,3 +330,37 @@ jobs:
# different to SciGateway preprod
- name: Diff SQL dumps
run: diff -s ~/generator_script_dump_main.sql ~/generator_script_dump_1.sql

docker:
# This job triggers only if all the other jobs succeed and does different things depending on the context.
# The job builds the Docker image in all cases and also pushes the image to Harbor only if something is
# pushed to the k8s-deployment branch.
needs: [tests, linting, formatting, safety, generator-script-testing]
name: Docker
runs-on: ubuntu-20.04
steps:
- name: Check out repo
uses: actions/checkout@v2

- name: Login to Harbor
uses: docker/login-action@v1
with:
registry: harbor.stfc.ac.uk/datagateway
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: harbor.stfc.ac.uk/datagateway/datagateway-api

# TODO - Change github.ref to refs/heads/main before merging k8s-deployment into main
- name: ${{ github.event_name == 'push' && github.ref == 'refs/heads/k8s-deployment' && 'Build and push Docker image to Harbor' || 'Build Docker image' }}
uses: docker/build-push-action@v2
with:
context: .
# TODO - Change github.ref to refs/heads/main before merging k8s-deployment into main
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/k8s-deployment' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}