Test - Helmfile raw #206
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test - Helmfile raw | |
on: | |
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | |
# # | |
# # Added pull_request to register workflow from the PR. | |
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | |
# pull_request: {} | |
workflow_dispatch: {} | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup | |
run: echo "Do setup" | |
- id: random | |
shell: bash | |
run: |- | |
echo "password=$(echo $RANDOM | md5sum | head -c 20)" >> $GITHUB_OUTPUT | |
echo "environment=$(echo $RANDOM | md5sum | head -c 20)" >> $GITHUB_OUTPUT | |
outputs: | |
random: ${{ steps.random.outputs.password }} | |
environment: ${{ steps.random.outputs.environment }} | |
test: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
needs: [setup] | |
services: | |
localstack: | |
image: localstack/localstack:2.1.0 | |
ports: | |
- 4566:4566 | |
- 4510-4559:4510-4559 | |
credentials: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
path: ./action | |
- run: | | |
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \ | |
--name "/platform/default/${{ needs.setup.outputs.environment }}/default_ingress_domain" \ | |
--type "SecureString" \ | |
--value "example.com" | |
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \ | |
--name "/platform/default/${{ needs.setup.outputs.environment }}/default_alb_ingress_group" \ | |
--type "SecureString" \ | |
--value "default" \ | |
--debug | |
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \ | |
--name "/platform/default/_metadata/kube_version" \ | |
--type "SecureString" \ | |
--value "1.15" \ | |
--debug | |
env: | |
AWS_ACCESS_KEY_ID: test | |
AWS_SECRET_ACCESS_KEY: test | |
AWS_DEFAULT_REGION: us-east-1 | |
## Use localhost to connect localstack because the commands runs not in a container | |
AWS_ENDPOINT_OVERRIDE: http://localhost:4566 | |
- uses: ./action | |
id: current | |
with: | |
cluster: https://github.com/cloudposse/argocd-deploy-non-prod-test/blob/main/plat/ue2-sandbox/apps | |
toolchain: helmfile | |
environment: ${{ needs.setup.outputs.environment }} | |
namespace: ${{ needs.setup.outputs.environment }} | |
path: ./action/test/helmfile/helmfile.yaml | |
application: test-app | |
ssm-path: platform/default | |
github-pat: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} | |
image: nginx | |
image-tag: ${{ needs.setup.outputs.random }} | |
synchronously: true | |
repository: ${{ github.repository }} | |
ref: ${{ github.sha }} | |
env: | |
AWS_ACCESS_KEY_ID: test | |
AWS_SECRET_ACCESS_KEY: test | |
AWS_DEFAULT_REGION: us-east-1 | |
## Use localhost to connect localstack because the commands runs not in a container | |
AWS_ENDPOINT_OVERRIDE: http://localhost:4566 | |
## Use localstack to connect localstack because the chamber runs in a container | |
CHAMBER_AWS_SSM_ENDPOINT: http://localstack:4566/ | |
outputs: | |
status: ${{ steps.current.outcome }} | |
result: ${{ steps.current.outputs.webapp-url }} | |
sha: ${{ steps.current.outputs.sha }} | |
argocd: | |
runs-on: ubuntu-latest | |
needs: [setup] | |
steps: | |
- name: Checkout Argo Configuration | |
uses: actions/checkout@v3 | |
with: | |
repository: cloudposse/argocd-deploy-non-prod-test | |
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} | |
path: ./status | |
- name: wait-for-commit | |
id: wait | |
shell: bash | |
run: | | |
echo "Wait for commit" | |
SEEK_MESSAGE="Deploy cloudposse/github-action-deploy-argocd SHA ${{ github.sha }} RUN ${{ github.run_id }} ATEMPT ${{ github.run_attempt }}" | |
echo ${SEEK_MESSAGE} | |
cd ./status | |
max_iterations=50 | |
wait_seconds=10 | |
iterations=0 | |
while true | |
do | |
iterations=$((iterations+1)) | |
echo "Attempt $iterations" | |
sleep $wait_seconds | |
set +e | |
git pull | |
git log --format=%B -n 50 | grep "${SEEK_MESSAGE}" | |
COMMIT_APPEARS=$? | |
set -e | |
if [ $COMMIT_APPEARS -eq 0 ]; then | |
echo "Commit appers" | |
break | |
fi | |
if [ "$iterations" -ge "$max_iterations" ]; then | |
echo "Loop Timeout" | |
exit 1 | |
fi | |
done | |
SHA=$(git log --format=oneline -n 50 | grep "${SEEK_MESSAGE}" | cut -d' ' -f1 | head -1) | |
echo "sha=${SHA}" >> $GITHUB_OUTPUT | |
- name: set status | |
uses: myrotvorets/set-commit-status-action@master | |
with: | |
repo: ${{ github.repository }} | |
sha: ${{ github.sha }} | |
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} | |
status: success | |
context: continuous-delivery/${{ needs.setup.outputs.environment }}.test-app | |
assert: | |
runs-on: ubuntu-latest | |
needs: [setup, test, argocd] | |
steps: | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "success" | |
actual: "${{ needs.test.outputs.status }}" | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "https://example-app.example.com/dashboard" | |
actual: "${{ needs.test.outputs.result }}" | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "" | |
actual: "${{ needs.test.outputs.sha }}" | |
comparison: notEqual | |
- name: Checkout Argo Configuration | |
uses: actions/checkout@v3 | |
with: | |
repository: cloudposse/argocd-deploy-non-prod-test | |
ref: ${{ needs.test.outputs.sha }} | |
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} | |
path: ./assert | |
- name: Get Image | |
id: image | |
shell: bash | |
run: |- | |
image=$( \ | |
yq eval-all '.spec.template.spec.containers[].image | select(. != null)' \ | |
./assert/plat/ue2-sandbox/apps/${{ needs.setup.outputs.environment }}/test-app/manifests/resources.yaml \ | |
) | |
echo "value=${image}" >> $GITHUB_OUTPUT | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "nginx:${{ needs.setup.outputs.random }}" | |
actual: "${{ steps.image.outputs.value }}" | |
- name: Get Ingress | |
id: ingress | |
shell: bash | |
run: |- | |
ingress=$( \ | |
yq eval-all 'select(.kind == "Ingress") | .apiVersion' \ | |
./assert/plat/ue2-sandbox/apps/${{ needs.setup.outputs.environment }}/test-app/manifests/resources.yaml \ | |
) | |
echo "value=${ingress}" >> $GITHUB_OUTPUT | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "networking.k8s.io/v1beta1" | |
actual: "${{ steps.ingress.outputs.value }}" | |
- name: Get Name | |
id: name | |
shell: bash | |
run: |- | |
name=$( \ | |
yq eval-all '.name' \ | |
./assert/plat/ue2-sandbox/apps/${{ needs.setup.outputs.environment }}/test-app/config.yaml \ | |
) | |
echo "value=${name}" >> $GITHUB_OUTPUT | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "${{ needs.setup.outputs.environment }}.test-app" | |
actual: "${{ steps.name.outputs.value }}" | |
- name: Get ref | |
id: app_commit | |
shell: bash | |
run: |- | |
app_commit=$( \ | |
yq eval-all '.app_commit' \ | |
./assert/plat/ue2-sandbox/apps/${{ needs.setup.outputs.environment }}/test-app/config.yaml \ | |
) | |
echo "value=${app_commit}" >> $GITHUB_OUTPUT | |
- uses: nick-fields/assert-action@v1 | |
with: | |
expected: "${{ github.sha }}" | |
actual: "${{ steps.app_commit.outputs.value }}" | |
teardown: | |
runs-on: ubuntu-latest | |
needs: [assert] | |
if: ${{ always() }} | |
steps: | |
- name: Tear down | |
run: echo "Do Tear down" |