Skip to content

Merge pull request #14 from nickel/auth #13

Merge pull request #14 from nickel/auth

Merge pull request #14 from nickel/auth #13

Workflow file for this run

name: Build and push Docker image
on:
push:
branches:
- main
jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with:
ref: "main"
fetch-depth: 0
- name: 'Login to Docker Registry'
uses: docker/login-action@v2
with:
registry: ${{secrets.DOCKER_REGISTRY_HOST}}
username: ${{secrets.DOCKER_REGISTRY_USER}}
password: ${{secrets.DOCKER_REGISTRY_PASS}}
- name: 'Build & push image'
run: |
docker build . --tag ${{secrets.DOCKER_REGISTRY_HOST}}/${{github.repository}}:latest \
--tag ${{secrets.DOCKER_REGISTRY_HOST}}/${{github.repository}}:${{ github.sha }}
docker push ${{secrets.DOCKER_REGISTRY_HOST}}/${{github.repository}}:latest
docker push ${{secrets.DOCKER_REGISTRY_HOST}}/${{github.repository}}:${{ github.sha }}
- name: 'Trigger external workflow'
run: |
infra_repo_owner=${{ secrets.INFRA_REPO_OWNER }}
infra_repo_name=${{ secrets.INFRA_REPO_NAME }}
infra_repo_workflow_id=${{ secrets.INFRA_REPO_WORKFLOW_ID }}
service=${{ github.repository }}
version=${{ github.sha }}
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$infra_repo_owner/$infra_repo_name/actions/workflows/$infra_repo_workflow_id/dispatches \
-d "{ \"ref\":\"main\", \"inputs\":{\"service\":\"$service\", \"version\":\"$version\"}}"