Skip to content

Commit

Permalink
Switched to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lmakarov committed Nov 23, 2021
1 parent ccc500c commit cdad90d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 38 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish Templates

on:
push:
branches:
- "**"
tags:
- 'v*.*.*'
workflow_dispatch: # Allow manually triggering a build

defaults:
run:
shell: bash

env:
AWS_REGION: us-east-2
AWS_ACCESS_KEY_ID: AKIAIPJXMNOEV65OMURA
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_BUCKET: docksal-aws-templates
UPLOAD_DIR: sandbox-server
LOCAL_DIR: build

jobs:
aws-templates:
name: "Publish: ${{ matrix.template }} template"
runs-on: ubuntu-20.04

strategy:
fail-fast: false # Don't cancel other jobs if one fails
matrix:
template:
- basic
- advanced

steps:
-
name: Checkout
uses: actions/checkout@v2
# -
# name: Environment variables
# run: |
# # Export variables for further steps
# echo "GIT_SHA7=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
# echo "BUILD_CONTEXT=${VERSION:-.}" >> ${GITHUB_ENV}
# echo "BUILD_IMAGE_TAG=${IMAGE}:${VERSION_PREFIX}${VERSION}build" >> ${GITHUB_ENV}
# -
# name: Install AWS CLI
# run: |
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
# unzip awscliv2.zip
# sudo ./aws/install
-
name: Build and publish template
env:
TEMPLATE_TYPE: ${{ matrix.template }}
run: |
cd aws-cloudformation && ./scripts/bash2yaml startup-${TEMPLATE_TYPE}.sh tpl-${TEMPLATE_TYPE}.yaml
aws cloudformation package --template-file template.yaml --s3-bucket null --output-template-file package.json --use-json
mkdir -p ${LOCAL_DIR} && mv -f package.json ${LOCAL_DIR}/${TEMPLATE_TYPE}.json
tmp=$(basename $(mktemp -u))
aws s3 cp ${LOCAL_DIR}/${TEMPLATE_TYPE}.json s3://${S3_BUCKET}/${tmp} --acl public-read
res=$(aws cloudformation validate-template --region ${AWS_REGION} --template-url https://${S3_BUCKET}.s3.amazonaws.com/${tmp} || echo "error")
aws s3 rm s3://${S3_BUCKET}/${tmp}
if [ "${res}" == "error" ]; then exit 1; fi
${GITHUB_WORKSPACE}/scripts/upload-to-s3.sh
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

13 changes: 7 additions & 6 deletions scripts/upload-to-s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@

is_edge ()
{
[[ "${TRAVIS_BRANCH}" == "develop" ]]
[[ "${GITHUB_REF}" == "refs/heads/develop" ]]
}

is_stable ()
{
[[ "${TRAVIS_BRANCH}" == "master" ]]
[[ "${GITHUB_REF}" == "refs/heads/master" ]]
}

is_release ()
{
[[ "${TRAVIS_TAG}" != "" ]]
[[ "${GITHUB_REF}" =~ "refs/tags/" ]]
}

# Check whether the current build is for a pull request
is_pr ()
{
[[ "${TRAVIS_PULL_REQUEST}" != "false" ]]
# GITHUB_HEAD_REF is only set for pull requests
[[ "${GITHUB_HEAD_REF}" != "" ]]
}
# ---------------------------- #

# Extract version parts from release tag
IFS='.' read -a ver_arr <<< "$TRAVIS_TAG"
IFS='.' read -a ver_arr <<< ${GITHUB_REF#refs/tags/}
VERSION_MAJOR=${ver_arr[0]#v*} # 2.7.0 => "2"
VERSION_MINOR=${ver_arr[1]} # "2.7.0" => "7"
VERSION_HOTFIX=${ver_arr[2]} # "2.7.0" => "0"
Expand All @@ -35,7 +36,7 @@ STABLE_UPLOAD_DIR=${UPLOAD_DIR}/stable
RELEASE_UPLOAD_DIR_MAJOR=${UPLOAD_DIR}/v${VERSION_MAJOR}
RELEASE_UPLOAD_DIR_MINOR=${UPLOAD_DIR}/v${VERSION_MAJOR}.${VERSION_MINOR}
RELEASE_UPLOAD_DIR_HOTFIX=${UPLOAD_DIR}/v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_HOTFIX}
BRANCH_UPLOAD_DIR=${UPLOAD_DIR}/branch/${TRAVIS_BRANCH}
BRANCH_UPLOAD_DIR=${UPLOAD_DIR}/branch/${GITHUB_REF#refs/heads/}

# Skip pull request
is_pr && exit 0
Expand Down

0 comments on commit cdad90d

Please sign in to comment.