chore: created new ci for ECR #3
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: CI-ECR | |
on: | |
push: | |
branches: | |
- main | |
- v* | |
pull_request: | |
branches: | |
- main | |
- v* | |
jobs: | |
build: | |
strategy: | |
matrix: | |
version: | |
- tileserver: "v3.1.1" | |
mbtiles: "0-18_20210325T212157Z" | |
- tileserver: "v3.1.1" | |
mbtiles: "0-18_20220815T202133Z" | |
- tileserver: "v3.1.1" | |
mbtiles: "0-18_20240612T202043Z" | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: sg-tileserver-gl | |
SELF_VERSION: "v1.1.0" | |
TILESERVER_GL_VERSION: "${{ matrix.version.tileserver }}" | |
MBTILES_TAG: "${{ matrix.version.mbtiles }}" | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Set TAG_NAME as env var export | |
run: |- | |
SUFFIX_TAG="tileserver-${TILESERVER_GL_VERSION}_mbtiles-${MBTILES_TAG}" | |
echo "TAG_NAME=${SELF_VERSION}_${SUFFIX_TAG}" >> $GITHUB_ENV | |
echo "OPENRESTY_SUFFIX=_openresty" >> $GITHUB_ENV | |
SELF_X_VERSION="$(echo ${SELF_VERSION} | cut -d . -f 1)" | |
echo "X_TAG_NAME=${SELF_X_VERSION}_${SUFFIX_TAG}" >> $GITHUB_ENV | |
SELF_XY_VERSION="$(echo ${SELF_VERSION} | cut -d . -f 1,2)" | |
echo "XY_TAG_NAME=${SELF_XY_VERSION}_${SUFFIX_TAG}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 12 | |
- name: Install tera-cli | |
run: |- | |
wget https://github.com/guangie88/tera-cli/releases/download/v0.4.0/tera_linux_amd64 -O /tmp/tera | |
chmod +x /tmp/tera | |
- name: Check differences between ci.yml and ci.yml.tmpl | |
run: |- | |
cp .github/workflows/ci.yml .github/workflows/ci.yml.backup | |
TERA=/tmp/tera .github-templates/apply-vars.sh | |
if ! diff .github/workflows/ci.yml .github/workflows/ci.yml.backup; then echo "ci.yml.tmpl and ci.yml differs!" && exit 1; fi | |
- name: Run setup-scripts | |
run: |- | |
MBTILES_TAG=${MBTILES_TAG} ./setup.sh | |
- name: Build Docker image (native) | |
run: |- | |
docker build . -t "${IMAGE_NAME}:${TAG_NAME}" \ | |
--target native \ | |
--build-arg TILESERVER_GL_VERSION="${TILESERVER_GL_VERSION}" | |
- name: Build Docker image (with openresty) | |
run: |- | |
docker build . -t "${IMAGE_NAME}:${TAG_NAME}${OPENRESTY_SUFFIX}" \ | |
--build-arg TILESERVER_GL_VERSION="${TILESERVER_GL_VERSION}" | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
audience: sts.amazonaws.com | |
role-to-assume: arn:aws:iam::802909931189:role/GithubActionsDSAIDGOVSG | |
aws-region: ap-southeast-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Push Docker images to ECR | |
run: bash push-images-ecr.sh | |
env: | |
ECR_REGISTRY: 802909931189.dkr.ecr.ap-southeast-1.amazonaws.com | |
# if: github.event_name == 'push' |