Skip to content

deploy

deploy #68

Workflow file for this run

name: deploy
# Controls when the workflow will run
on:
push:
branches: [ staging, production ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
staging-deploy:
if: github.ref == 'refs/heads/staging'
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: staging
steps:
- name: Get current date
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: go build -v
# - name: Test
# run: go test -v ./...
- name: Clone documentation
run: |
git clone https://github.com/gazebosim/docs
(cd docs; git log -n 1)
- name: Generate deployment package
run: zip -r deploy_package.zip . -x '*.git*'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"
- name: Upload package to S3 bucket
run: aws s3 cp deploy_package.zip s3://api.gazebosim.org/
- name: Create new ElasticBeanstalk Application Version
run: |
aws elasticbeanstalk create-application-version \
--application-name gazebosim-web \
--source-bundle S3Bucket="api.gazebosim.org",S3Key="deploy_package.zip" \
--version-label "ver-${{ github.sha }}-$NOW" \
--description "commit-sha-${{ github.sha }}-date-$NOW"
- name: Deploy new ElasticBeanstalk Application Version
# Add the `always` in case the application version from the previous
# step already exists, which would cause a failure.
if: always()
run: aws elasticbeanstalk update-environment --environment-name gazebosim-staging --version-label "ver-${{ github.sha }}-$NOW"
production-deploy:
if: github.ref == 'refs/heads/production'
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: production
steps:
- name: Get current date
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: go build -v
# - name: Test
# run: go test -v ./...
- name: Clone documentation
run: |
git clone https://github.com/gazebosim/docs
(cd docs; git log -n 1)
- name: Generate deployment package
run: zip -r deploy_package.zip . -x '*.git*'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"
- name: Upload package to S3 bucket
run: aws s3 cp deploy_package.zip s3://api.gazebosim.org/
- name: Create new ElasticBeanstalk Application Version
run: |
aws elasticbeanstalk create-application-version \
--application-name gazebosim-web \
--source-bundle S3Bucket="api.gazebosim.org",S3Key="deploy_package.zip" \
--version-label "ver-${{ github.sha }}-$NOW" \
--description "commit-sha-${{ github.sha }}-date-$NOW"
- name: Deploy new ElasticBeanstalk Application Version
# Add the `always` in case the application version from the previous
# step already exists, which would cause a failure.
if: always()
run: aws elasticbeanstalk update-environment --environment-name gazebosim-production --version-label "ver-${{ github.sha }}-$NOW"