This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (76 loc) · 3.05 KB
/
build-container.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: Build container + Deploy
on:
workflow_dispatch:
inputs:
tag:
description: 'Specific container tag from container repository'
required: true
subdomain:
description: 'Subdomain to deploy to'
required: true
dockerrepo:
description: 'Docker repo to deploy images to'
required: true
expire:
description: 'When to kill the image (Defaults to 1 week) (etc. yyyy-mm-dd)'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
steps:
# Setup environment
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.event.inputs.tag }}
restore-keys: |
${{ runner.os }}-buildx-
# Do testing
- name: Build testing container
uses: docker/build-push-action@v2
with:
tags: hackthe6ix/${{ github.event.inputs.dockerrepo }}:testing
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-from: type=local,src=/tmp/.buildx-cache
target: testing
push: false
load: true
- name: Run tests
run: /usr/bin/docker run -v ${{ github.workspace }}/static:/usr/var/app/static -v ${{ github.workspace }}/src:/usr/var/app/src hackthe6ix/${{ github.event.inputs.dockerrepo }}:testing;
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
tags: hackthe6ix/${{ github.event.inputs.dockerrepo }}:${{ github.event.inputs.tag }}
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
cache-from: type=local,src=/tmp/.buildx-cache
target: deploy
push: true
# Clean up cache
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# Trigger preview creation
- uses: convictional/trigger-workflow-and-wait@v1.3.0
with:
github_token: ${{ secrets.GH_ACCESS_TOKEN }}
workflow_file_name: deploy-container.yml
inputs: '{ "tag": "${{ github.event.inputs.tag }}", "subdomain": "${{ github.event.inputs.subdomain }}", "expire": "${{ github.event.inputs.expire }}", "dockerrepo": "${{ github.event.inputs.dockerrepo }}" }'
repo: ${{ github.event.repository.name }}
owner: hack-the-6ix
# Print preview link
- uses: mshick/add-pr-comment@v1
with:
message: |
**Preview link:** [https://${{ github.event.inputs.subdomain }}.hackthe6ix.com](https://${{ github.event.inputs.subdomain }}.hackthe6ix.com)
allow-repeats: true
repo-token: ${{ github.token }}