Skip to content

Commit 18005c8

Browse files
Update, managed by Terraform
1 parent 1a08b26 commit 18005c8

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/build.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
staging:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v1
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v1
19+
20+
- name: Set up Cloud SDK
21+
uses: google-github-actions/setup-gcloud@v0
22+
with:
23+
project_id: monom-cicd-tools
24+
service_account_key: ${{ secrets.SA_KEY }}
25+
export_default_credentials: true
26+
27+
- name: Docker login
28+
run: gcloud auth configure-docker
29+
30+
- name: Cache Docker layers
31+
uses: actions/cache@v2
32+
with:
33+
path: /tmp/.buildx-cache
34+
key: ${{ runner.os }}-buildx-${{ github.sha }}
35+
restore-keys: |
36+
${{ runner.os }}-buildx-
37+
38+
- name: Build and push
39+
id: docker_build
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: .
43+
file: ./Dockerfile
44+
push: true
45+
tags: gcr.io/monom-cicd-tools/${{ github.event.repository.name }}:${{ github.event.release.tag_name }}
46+
cache-from: type=local,src=/tmp/.buildx-cache
47+
cache-to: type=local,dest=/tmp/.buildx-cache-new
48+
# This ugly bit is necessary if you don't want your cache to grow forever
49+
# till it hits GitHub's limit of 5GB.
50+
# Temp fix
51+
# https://github.com/docker/build-push-action/issues/252
52+
# https://github.com/moby/buildkit/issues/1896
53+
54+
- name: Move cache
55+
run: |
56+
rm -rf /tmp/.buildx-cache
57+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
58+
59+
- name: Slack notification
60+
uses: act10ns/slack@v1
61+
if: always()
62+
with:
63+
status: ${{ job.status }}
64+
channel: '#deployments'
65+
env:
66+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
67+
68+
- name: Delete tag and release when it fails
69+
uses: dev-drprasad/delete-tag-and-release@v0.2.0
70+
if: failure()
71+
with:
72+
delete_release: true
73+
tag_name: ${{ github.event.release.tag_name }}
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Clean gcr images
78+
run: |
79+
curl -X POST -H "Authorization: Bearer $(gcloud auth print-identity-token)" https://gcr-cleaner-m3srfcef5q-ew.a.run.app/http -d '{"repos":["gcr.io/monom-cicd-tools/${{ github.event.repository.name }}"], "tag_filter_all":".*", "dry_run":false,"keep":10}'

0 commit comments

Comments
 (0)