-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (54 loc) · 2.02 KB
/
build-and-deploy-to-staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Deployed to https://staging.api.fairhub.io
name: (staging) Build and push api image to Azure Container Registry
on:
push:
branches:
- staging
pull_request:
types: [closed]
branches:
- staging
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and push Docker image
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
env:
AZURE_REGISTRY_LOGIN_SERVER: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}
AZURE_REGISTRY_USERNAME: ${{ secrets.AZURE_REGISTRY_USERNAME }}
AZURE_REGISTRY_PASSWORD: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Wait for linting to pass
uses: lewagon/[email protected]
with:
ref: staging
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: "Run linters (3.10)"
- name: Wait for tests to pass
uses: lewagon/[email protected]
with:
ref: staging
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: "Run tests (3.10)"
- name: Login to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
- name: Get GitHub short SHA
id: git_sha
run: echo ::set-output name=sha::$(git rev-parse --short ${{ github.sha }})
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/fairhub-api:staging,${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/fairhub-api:${{ steps.git_sha.outputs.sha }}