Skip to content

Docker image for username service #9

Docker image for username service

Docker image for username service #9

name: Usrename Service
on:
push:
branches:
- master
pull_request:
paths:
- ".github/workflows/username_service.yaml"
- "stfc-username-service/**"
jobs:
push_dev_image_harbor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Harbor
uses: docker/login-action@v3
with:
registry: harbor.stfc.ac.uk
username: ${{ secrets.STAGING_HARBOR_USERNAME }}
password: ${{ secrets.STAGING_HARBOR_TOKEN }}
- name: Set commit SHA for later
id: commit_sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push to staging project
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
context: "{{defaultContext}}:stfc-username-service"
tags: "harbor.stfc.ac.uk/stfc-cloud-staging/stfc-username-service:${{ steps.commit_sha.outputs.sha_short }}"
- name: Inform of tagged name
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud-staging/stfc-username-service:${{ steps.commit_sha.outputs.sha_short }}"
push_release_image_harbor:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Harbor
uses: docker/login-action@v3
with:
registry: harbor.stfc.ac.uk
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Get release tag for later
id: release_tag
run: echo "version=$(cat stfc-username-service/version.txt)" >> $GITHUB_OUTPUT
- name: Check if release file has updated
uses: dorny/paths-filter@v3
id: release_updated
with:
filters: |
version:
- 'stfc-username-service/version.txt'
- name: Build and push on version change
uses: docker/build-push-action@v6
if: steps.release_updated.outputs.version == 'true'
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
context: "{{defaultContext}}:stfc-username-service"
tags: "harbor.stfc.ac.uk/stfc-cloud/stfc-username-service:v${{ steps.release_tag.outputs.version }}"
- name: Inform of tagged name
if: steps.release_updated.outputs.version == 'true'
run: echo "Image published to harbor.stfc.ac.uk/stfc-cloud/stfc-username-service:v${{ steps.release_tag.outputs.version }}"