chore(release): cut 2.33.0 [skip release] #422
Workflow file for this run
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: 'dhis2-docker publish' | |
on: | |
push: | |
branches: | |
- master | |
- next | |
env: | |
ECR_REPOSITORY: dhis2/app-hub | |
HUB_REPOSITORY: dhis2/app-hub | |
AWS_REGION: eu-west-1 | |
IMAGE: apphub | |
DEBUG: apphub* | |
GIT_AUTHOR_NAME: '@dhis2-bot' | |
GIT_AUTHOR_EMAIL: '[email protected]' | |
GIT_COMMITTER_NAME: '@dhis2-bot' | |
GIT_COMMITTER_EMAIL: '[email protected]' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}} | |
- uses: dhis2/action-semantic-release@update-deps | |
with: | |
publish-github: true | |
github-token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: [release] | |
if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}} | |
- 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: ${{ env.AWS_REGION }} | |
- name: Login to Docker Hub | |
run: echo ${{ secrets.DHIS2_BOT_DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DHIS2_BOT_DOCKER_HUB_USERNAME }} --password-stdin | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
SHA_TAG: ${{ github.sha }} | |
run: | | |
docker build . --file Dockerfile --tag $IMAGE | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
[ "$VERSION" == "master" ] && VERSION=latest | |
[ "$VERSION" == "next" ] && VERSION=staging | |
echo VERSION=$VERSION | |
# docker hub | |
docker tag $IMAGE $HUB_REPOSITORY:$VERSION | |
docker tag $IMAGE $HUB_REPOSITORY:$SHA_TAG | |
docker push $HUB_REPOSITORY:$VERSION | |
docker push $HUB_REPOSITORY:$SHA_TAG | |
# aws ecr | |
docker tag $IMAGE $ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG | |
docker tag $IMAGE $ECR_REGISTRY/$ECR_REPOSITORY:$VERSION | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$VERSION | |
# set the image name for task-def step | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG" | |
echo "::set-output name=version::$VERSION" | |
sed -i "s|AUTOINJECTED_GH_ACTIONS|$ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG|g" Dockerrun.aws.json | |
cat Dockerrun.aws.json | |
zip -r deploy.zip .platform Dockerrun.aws.json | |
- name: Deploy to Staging | |
if: steps.build-image.outputs.version == 'staging' | |
uses: einaregilsson/beanstalk-deploy@v6 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: app-hub | |
environment_name: staging-v2 | |
version_label: app-hub-staging-${{ github.run_id }}_${{ github.run_number}} | |
region: ${{ env.AWS_REGION }} | |
deployment_package: deploy.zip | |
- name: Deploy to Production | |
if: steps.build-image.outputs.version == 'latest' | |
uses: einaregilsson/beanstalk-deploy@v6 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: app-hub | |
environment_name: prod-v2 | |
version_label: app-hub-prod-${{ github.run_id }}_${{ github.run_number}} | |
region: ${{ env.AWS_REGION }} | |
deployment_package: deploy.zip |