forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (82 loc) · 2.52 KB
/
ci.yaml
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
88
89
90
91
92
name: Golang CI
on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize]
schedule:
- cron: '15 3 * * 0'
jobs:
build:
name: CI Build
runs-on: ubuntu-22.04
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Setup tools
run: |
go install golang.org/x/lint/golint@latest
- name: Checkout code
uses: actions/checkout@v4
- name: Check Formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "### Go formatting is off, please execute 'gofmt -w -s .' - see following diff: ###"
gofmt -s -d .
exit 1
fi
- name: Test Project
run: |
make test
- name: Build Project
run: |
make
docker_build:
runs-on: ubuntu-22.04
name: Docker Build
if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == 'rebuy-de/aws-nuke' && github.event.pull_request.user.login != 'dependabot[bot]')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate image tags
shell: bash
run: |
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
BRANCH="$(echo ${GITHUB_HEAD_REF} | tr '/' '_')"
echo "tags=quay.io/rebuy/aws-nuke:${BRANCH},docker.io/rebuy/aws-nuke:${BRANCH}" >> $GITHUB_OUTPUT
else
echo "tags=quay.io/rebuy/aws-nuke:main,docker.io/rebuy/aws-nuke:main,\
quay.io/rebuy/aws-nuke:latest,docker.io/rebuy/aws-nuke:latest" >> $GITHUB_OUTPUT
fi
id: generate_tags
- name: Set up QEMU
if: github.event_name != 'pull_request'
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.generate_tags.outputs.tags }}
platforms: ${{ github.event_name != 'pull_request' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}