Skip to content

Automated PR (gitops/production/ui-main) #455

Automated PR (gitops/production/ui-main)

Automated PR (gitops/production/ui-main) #455

name: ecspresso preview
on:
pull_request:
branches: ["main"]
paths:
- 'ecspresso/**'
# this workflow should be processed by FIFO
concurrency: ecspresso
jobs:
preview:
runs-on: "ubuntu-latest"
strategy:
matrix:
environment:
- stg
- prod
- reviewapps
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-1
- name: Install ecspresso
uses: kayac/ecspresso@v2
- name: ecspresso preview
id: preview
continue-on-error: true
working-directory: ecspresso
shell: bash -x {0}
run: |
failed=0
for config in $(find . -name "ecspresso.jsonnet" | grep -E "^./${{ matrix.environment }}" | grep -v "reviewapps/template" ); do
ecspresso --config=$config diff >> preview.stdout.txt 2> preview.stderr.txt
[ $? -ne 0 ] && failed=1 && break
done
echo "status=$failed" >> $GITHUB_OUTPUT
function no-color {
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"
}
echo "stdout<<EOF" >> $GITHUB_OUTPUT
cat preview.stdout.txt | no-color >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "stderr<<EOF" >> $GITHUB_OUTPUT
cat preview.stderr.txt | no-color >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: report for preview
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.preview.outputs.status == '0' }}
with:
header: "preview for ${{ matrix.environment }}"
message: |
<details>
<summary>:white_check_mark: Preview for ${{ matrix.environment }}</summary>
```diff
${{ steps.preview.outputs.stdout }}
```
</details>
- name: report error for preview
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.preview.outputs.status == '1' }}
with:
header: "preview for ${{ matrix.environment }}"
message: |
<details>
<summary>:fire: Preview failed for ${{ matrix.environment }}</summary>
```diff
${{ steps.preview.outputs.stderr }}
```
</details>
- name: raise error
if: ${{ steps.preview.outputs.status == '1' }}
run: exit 1