-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (80 loc) · 2.55 KB
/
docker-publish.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ trunk ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ trunk ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
packages: write
strategy:
matrix:
image: ['web', 'admin', 'postgres', 'api']
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PUSH_PAT }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ${{ matrix.image }}
build-args: |
REACT_APP_HOST=achievements.hackthemidlands.com
target: prod
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# terraform:
# name: 'Terraform'
# runs-on: ubuntu-latest
# environment: production
# # needs: build
# env:
# TF_VAR_tag: '${{ env.GITHUB_REF }}'
#
# defaults:
# run:
# shell: bash
#
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v1
# with:
# cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# - name: Terraform Init
# run: terraform -chdir=terraform init
# - name: Terraform Format
# run: terraform -chdir=terraform fmt
# - name: Terraform Plan
# run: terraform -chdir=terraform plan
# - name: Terraform Apply
# if: github.ref == 'refs/heads/trunk' && github.event_name == 'push'
# run: terraform -chdir=terraform apply -auto-approve