Skip to content

Alpha Release

Alpha Release #20

Workflow file for this run

name: Alpha 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 --prerelease alpha --skip.tag
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: |
version=$(node -p "require('./package.json').version")
branch=$(git rev-parse --abbrev-ref HEAD | sed 's/feature\///')
branch=${branch//[^a-zA-Z0-9_-]/-}
echo "version=$version-$branch" >> $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 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 }}