Release #60
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: Release | |
on: | |
workflow_dispatch: | |
jobs: | |
create-new-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Bump and Commit | |
run: | | |
npx standard-version | |
git push --follow-tags | |
push: | |
needs: create-new-release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
environment: docker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
# Get version from package.json | |
- name: Get version from package.json | |
id: version | |
run: echo "version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT | |
# Build the Docker image | |
- name: Build Docker image | |
run: docker build --cache-from democracy/democracy-server:latest -t democracy/democracy-server:${{ steps.version.outputs.version }} . | |
# Push the image to Docker Hub | |
- name: Push image to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to Docker Hub | |
run: | | |
docker tag democracy/democracy-server:${{ steps.version.outputs.version }} democracy/democracy-server:latest | |
docker push democracy/democracy-server:latest | |
docker push democracy/democracy-server:${{ steps.version.outputs.version }} | |
create-pull-request-to-infrastructure: | |
needs: push | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository where the pull request should be created | |
- name: Checkout target repository | |
uses: actions/checkout@v3 | |
with: | |
repository: demokratie-live/infrastructure | |
token: ${{ secrets.ACTION_INFRASTRUCTURE_PR }} | |
fetch-depth: 0 | |
ref: main | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
# Step 2: Create a new Branch | |
- name: Create a new branch | |
run: | | |
git checkout -b democracy-server-${{ needs.push.outputs.version }} | |
git push --set-upstream origin democracy-server-${{ needs.push.outputs.version }} | |
- name: Edit file | |
run: | | |
sed -i -E "s/image: democracy\/democracy-server:.*$/image: democracy\/democracy-server:${{ needs.push.outputs.version }}/g" kustomize/base/main/democracy-api-depl.yaml | |
git add kustomize/base/main/democracy-api-depl.yaml | |
git commit -m "chore(infrastructure): update Docker container version in Kubernetes YAML" | |
git push --set-upstream origin democracy-server-${{ needs.push.outputs.version }} | |
# Step 4: Create the pull request | |
- name: Create Pull Request | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/{owner}/{repo}/pulls | |
owner: 'demokratie-live' | |
repo: infrastructure | |
title: 'New version for democracy-server ${{ needs.push.outputs.version }}' | |
base: main | |
head: democracy-server-${{ needs.push.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACTION_INFRASTRUCTURE_PR }} |