Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

build: Update dockerfile #3

build: Update dockerfile

build: Update dockerfile #3

name: Build and deploy staging
on:
push:
branches:
- 'es/add-pipeline' # for testing
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: self-hosted
outputs:
docker-image-tag: ${{ steps.docker-image-tagger.outputs.docker-image-tag }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DD-HH-mm-ss
utcOffset: "+12:00"
- name: Generate image tag
uses: boost/[email protected]
id: docker-image-tagger
with:
branch: ${{github.ref_name}}
sha: ${{github.sha}}
- name: Configure AWS Credentials for PCO ECR
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PCO_ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PCO_ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-southeast-2
- name: Log in to PCO Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
id: login-ecr
- name: Build & push Docker image
env:
TAG: staging-${{ steps.docker-image-tagger.outputs.docker-image-tag }}
ECR_REPOSITORY: harvester
ECR_REGISTRY: 339713080802.dkr.ecr.ap-southeast-2.amazonaws.com
run: |
docker build \
--build-arg RAILS_ENV=staging \
--build-arg TIMEZONE=Pacific/Auckland \
-t ${{env.ECR_REPOSITORY}}:${{env.TAG}} .
docker tag ${{env.ECR_REPOSITORY}}:${{env.TAG}} ${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:${{env.TAG}}
docker push ${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:${{env.TAG}}
- name: Log out of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure SSH key for git
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PCO_KUBERNETES_PRIVATE_DEPLOY_KEY }}
- name: Adding Github SSH key
run: |
touch /home/runner/.ssh/known_hosts
ssh-keygen -f "/home/runner/.ssh/known_hosts" -R "github.com"
echo "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl" >> /home/runner/.ssh/known_hosts
echo "github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=" >> /home/runner/.ssh/known_hosts
echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=" >> /home/runner/.ssh/known_hosts
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
- name: Deploy staging
env:
TAG: staging-${{ needs.build.outputs.docker-image-tag }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Pipeline"
rm -rf pco-kubernetes
git clone [email protected]:boost/pco-kubernetes.git
cd pco-kubernetes
support/bin/generate_kubernetes_config_file -e staging -p harvester -b ${{github.ref_name}} -i ${{env.TAG}} -c -a ${{github.actor}}