-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (95 loc) · 3.01 KB
/
main.yaml
File metadata and controls
100 lines (95 loc) · 3.01 KB
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
93
94
95
96
97
98
99
100
name: Build and Publish Image
on:
push:
paths-ignore:
- '**/*.md'
branches:
- 'main'
- 'cs/*'
release:
types:
- released
jobs:
build-and-push-latest:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ohioit
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
registry: ghcr.io
password: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.DOCKER_IMAGE_TAG }}
cache: true
cache_registry: cache
build-and-push-branch:
if: startsWith(github.ref, 'refs/heads/cs/')
runs-on: ohioit
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Determine tag name from branch name
env:
BRANCH_NAME: "${{ github.event.pull_request.head.ref }}"
run: |
echo "DOCKER_IMAGE_TAG::$($BRANCH_NAME | cut -d '/' -f 2)" >> $GITHUB_OUTPUT
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
registry: ghcr.io
password: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.DOCKER_IMAGE_TAG }}
cache: true
cache_registry: cache
build-and-push-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ohioit
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Determine tag name from branch name
env:
TAG_NAME: "${{ github.event.pull_request.head.ref }}"
run: |
echo "DOCKER_IMAGE_TAG::$($TAG_NAME | cut -d '/' -f 3)" >> $GITHUB_OUTPUT
- name: Kaniko build
uses: aevea/action-kaniko@master
with:
registry: ghcr.io
password: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.DOCKER_IMAGE_TAG }}
cache: true
cache_registry: cache
delete-merged-docker-tags:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'cs/') }}
runs-on: ohioit
permissions:
contents: read
packages: write
steps:
- name: Determine tag name from branch name
env:
BRANCH_NAME: "${{ github.event.pull_request.head.ref }}"
run: |
echo "::set-output name=DOCKER_IMAGE_TAG::$(${BRANCH_NAME} | cut -d '/' -f 2)"
- name: Delete Docker tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_TAG: "${{ env.DOCKER_IMAGE_TAG }}"
run: |
TAG="${IMAGE_TAG}"
REPO=ohioit/vscode-devcontainer-base
curl -X DELETE \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://ghcr.io/v2/${REPO}/manifests/${TAG}"