Deploy main channel to dev #1
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: Deploy main channel to dev | |
on: | |
workflow_dispatch: | |
inputs: | |
git-tag: | |
description: 'Branch/hash/tag' | |
required: true | |
env: | |
project-directory: ./ | |
jobs: | |
release: | |
name: Build Frontend Project | |
runs-on: ubuntu-latest | |
if: | | |
!contains(github.event.head_commit.message, 'skip-ci') | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: git configure | |
run: | | |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf ssh://git@github.com | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
- name: npm clean install | |
run: npm ci | |
working-directory: ${{ env.project-directory }} | |
- run: npm i -g semantic-release @semantic-release/{git,exec,changelog} | |
- run: semantic-release --debug | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
# next.js build | |
- name: build next | |
run: npm run build | |
working-directory: ${{ env.project-directory }} | |
env: | |
NODE_ENV: production | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build snapshot and push on merge | |
id: docker_build_release | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile-dev | |
push: true | |
tags: greenstand/${{ github.event.repository.name }}-dev:${{ steps.package-version.outputs.current-version }} | |
- id: export_bumped_version | |
run: | | |
export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}" | |
echo "bumped_version=${BUMPED_VERSION}" >> $GITHUB_OUTPUT | |
outputs: | |
bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }} | |
deploy: | |
name: Deploy to dev env | |
runs-on: ubuntu-latest | |
needs: release | |
if: | | |
!contains(github.event.head_commit.message, 'skip-ci') && | |
github.event_name == 'push' && | |
github.repository == "Greenstand/${{ github.event.repository.name }}" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install kustomize | |
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash | |
- name: Run kustomize | |
run: (cd deployment/base && ../../kustomize edit set image greenstand/treetracker-web-map-client=greenstand/${{ github.event.repository.name }}-dev:${{ needs.release.outputs.bumped_version }} ) | |
- name: Install doctl for kubernetes | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DEV_DIGITALOCEAN_TOKEN }} | |
- name: Save DigitalOcean kubeconfig | |
run: doctl kubernetes cluster kubeconfig save ${{ secrets.DEV_CLUSTER_NAME }} | |
#- name: Delete completed migration jobs prior to deployment | |
# run: kubectl -n ${{ secrets.K8S_NAMESPACE }} delete job --ignore-not-found=true database-migration-job | |
- name: Update kubernetes resources | |
run: kustomize build deployment/overlays/development | kubectl apply -n ${{ secrets.K8S_NAMESPACE }} --wait -f - | |
#- name: Attempt to wait for migration job to complete | |
# run: kubectl wait -n ${{ secrets.K8S_NAMESPACE }} --for=condition=complete --timeout=45s job/database-migration-job | |
# deploy: | |
# name: Deploy to STAGING CDN | |
# runs-on: ubuntu-latest | |
# needs: frontend | |
# if: | | |
# github.repository == "Greenstand/${{ github.event.repository.name }}" | |
# steps: | |
# - uses: actions/checkout@v2 | |
# - name: Download bundled frontend resources | |
# uses: actions/download-artifact@v2 | |
# with: | |
# name: frontend-bundle | |
# path: build | |
# - name: Configure AWS credentials | |
# uses: aws-actions/configure-aws-credentials@v1 | |
# with: | |
# aws-access-key-id: ${{ secrets.PROD_AWS_KEY_ID }} | |
# aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET }} | |
# aws-region: us-east-1 | |
# - name: Copy front end resources to s3 bucket | |
# run: | | |
# aws s3 sync build s3://${{ secrets.STAGING_CDN_S3_BUCKET }} --delete | |
# - name: Invalidate cloudfront caches | |
# run: | | |
# aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_CDN_DISTRIBUTION_ID }} --paths "/*" |