-
Notifications
You must be signed in to change notification settings - Fork 20
53 lines (49 loc) · 2.31 KB
/
ci-build-image.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
name: CI Build / Push Image
on:
repository_dispatch:
types: [build-image-command]
env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }}
DEFAULT_TAG: SNAPSHOT-PR-${{ github.event.client_payload.github.payload.issue.number }}
FULL_NAME: fabric8-analytics-f8a-stacks-report
jobs:
Build-push-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git fetch origin +refs/pull/${{ github.event.client_payload.github.payload.issue.number }}/merge
git checkout FETCH_HEAD
- name: Create comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
:test_tube: [CI has Started Image Build]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})
- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.event.client_payload.github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Build Image
run: docker build --no-cache -t ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}} -f Dockerfile .
- name: Push Image
run: docker push ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}}
- name: Create success comment
if: success()
uses: peter-evans/create-or-update-comment@v1
env:
IMAGE_URL: ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}}
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
:v: [Image Build Successfull]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) @${{github.event.client_payload.github.actor}}, Avaliable at: ```${{ env.IMAGE_URL }}```
- name: Create fail comment
if: failure()
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
:facepalm: [Build and Push Image Failed]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})