-
Notifications
You must be signed in to change notification settings - Fork 289
76 lines (65 loc) · 2.36 KB
/
Copy pathbuild-and-push.yml
File metadata and controls
76 lines (65 loc) · 2.36 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
name: Build and push stellar-docs
# Deployed to: https://github.com/stellar/stellar-docs
#
# Converted from the Jenkins pipeline (Jenkinsfile-stellar-docs). On every push
# to main (or manual dispatch) builds the stellar-docs docker image (with
# translations), pushes it to the prd ECR repo (prd/stellar-docs:<sha>), and
# also pushes it as dev/stellar-docs:latest for PR previews.
on:
push:
branches:
- main
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
SLACK_CHANNEL: docs-builds
jobs:
build-and-push:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Determine image label
id: vars
run: echo "label=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: ECR login
id: ecr-login
uses: stellar/actions/sdf-ecr-login@main
- name: Build and push docker image
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.ecr-registry }}
LABEL: ${{ steps.vars.outputs.label }}
run: |
set -eu
export TAG="${ECR_REGISTRY}/prd/stellar-docs:${LABEL}"
make docker-build
ecr-push "${TAG}"
# Push image with latest tag to dev registry for the PR previews.
DEV_TAG="${ECR_REGISTRY}/dev/stellar-docs:latest"
docker tag "${TAG}" "${DEV_TAG}"
ecr-push "${DEV_TAG}"
- name: Slack notification — success
if: success()
uses: slackapi/slack-github-action@0d95c9a7becc1e6e297d76df9bc735c44f4cbcbc # v3.0.5
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "${{ env.SLACK_CHANNEL }}",
"text": "Docs build complete for ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}."
}
- name: Slack notification — failure
if: failure()
uses: slackapi/slack-github-action@0d95c9a7becc1e6e297d76df9bc735c44f4cbcbc # v3.0.5
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "${{ env.SLACK_CHANNEL }}",
"text": "Docs build failed for ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}."
}