-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98b3bdf
commit cc5c583
Showing
1 changed file
with
20 additions
and
73 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,81 +2,28 @@ name: Deploy to production | |
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Get git tag | ||
run: | | ||
echo "GIT_TAG=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT | ||
id: set_git_vars | ||
- name: Push to GitHub Packages | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./docker/web/Dockerfile | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- dockerfile: ./docker/web/Dockerfile | ||
image: ghcr.io/${{ github.repository }}web | ||
- dockerfile: ./docker/worker/Dockerfile | ||
image: ghcr.io/${{ github.repository }}worker | ||
uses: ./.github/workflows/build_docker.yml | ||
with: | ||
image: ${{ matrix.image }} | ||
dockerfile: ${{ matrix.dockerfile }} | ||
|
||
deploy: | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Extract variables | ||
shell: bash | ||
run: | | ||
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_OUTPUT | ||
echo "TAG=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT | ||
echo "GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
echo "GIT_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
id: extract_variables | ||
|
||
- name: Checkout terraform config repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: 'datacite/mastino' | ||
persist-credentials: false | ||
- name: Commit changes to terraform config repository | ||
run: | | ||
export GIT_SHA=${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} | ||
export GIT_TAG=${{ steps.extract_variables.outputs.GIT_TAG }} | ||
wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz | ||
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz | ||
rm dockerize-linux-amd64-v0.6.0.tar.gz | ||
./dockerize -template prod-eu-west/services/analytics-api/keeshond.auto.tfvars.tmpl:prod-eu-west/services/analytics-api/keeshond.auto.tfvars | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add prod-eu-west/services/analytics-api/keeshond.auto.tfvars | ||
git commit -m "Adding keeshond git variables for commit ${{ steps.extract_variables.outputs.GIT_TAG }}" | ||
- name: Push changes | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
repository: 'datacite/mastino' | ||
branch: 'refs/heads/master' | ||
tags: false | ||
uses: ./.github/workflows/deployment.yml | ||
with: | ||
versionvar_filename: keeshond | ||
service_name: analytics-api | ||
env_name: prod-eu-west | ||
secrets: | ||
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |