Skip to content

Commit a654da1

Browse files
authored
Create docker-image.yml
Build my image and push it around
1 parent fbe8b24 commit a654da1

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build my gnutemps image and push to my registry
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
workflow_dispatch:
8+
jobs:
9+
build-n-push:
10+
runs-on: self-hosted
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set the image version
14+
id: vars
15+
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
16+
- name: Build the Docker image
17+
run: docker build . --file Dockerfile --tag macro.int.pgmac.net:5000/gnutemps:${{ inputs.tags || steps.vars.outputs.tag }}
18+
- name: Push to my internal registry
19+
if: github.ref == 'refs/heads/"master"'
20+
run: docker push macro.int.pgmac.net:5000/gnutemps:${{ inputs.tags || steps.vars.outputs.tag }}
21+
- name: Exit code failure
22+
if: failure()
23+
run: |
24+
echo "colour=danger" >> $GITHUB_ENV
25+
echo "icon=🛑" >> $GITHUB_ENV
26+
- name: Exit code cancelled
27+
if: cancelled()
28+
run: |
29+
echo "colour=warning" >> $GITHUB_ENV
30+
echo "icon=⚠" >> $GITHUB_ENV
31+
- name: Exit code success
32+
if: success()
33+
run: |
34+
echo "colour=good" >> $GITHUB_ENV
35+
echo "icon=✅" >> $GITHUB_ENV
36+
37+
- name: Send Slack message
38+
uses: slackapi/slack-github-action@v1.23.0
39+
with:
40+
payload: |
41+
{
42+
"channel": "builds",
43+
"attachments": [
44+
{
45+
"mrkdwn_in": ["text", "pretext"],
46+
"fallback": ${{ toJSON(join(github.event.commits.*.message, '<br>') || ':point_right: Manually triggered') }},
47+
"color": "${{ env.colour || 'grey' }}",
48+
"pretext": "${{ env.icon || '?' }} ${{ github.workflow }} (${{ github.ref_name }}) #${{ github.run_number }}",
49+
"author_name": "${{ github.triggering_actor || github.actor }}",
50+
"title": "${{ github.workflow }}",
51+
"title_link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
52+
"text": ${{ toJSON(join(github.event.commits.*.message, '\n') || ':point_right: Manually triggered') }}
53+
},
54+
{
55+
"blocks": [
56+
{
57+
"type": "section",
58+
"text": {
59+
"type": "mrkdwn",
60+
"text": "<${{ github.event.pull_request.html_url || github.event.head_commit.url || github.server_url }}|View commit>"
61+
}
62+
}
63+
]
64+
}
65+
]
66+
}
67+
env:
68+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
69+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 commit comments

Comments
 (0)