Build and Deploy #4
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
# .github/workflows/release.yml | |
name: Build and Deploy | |
on: | |
release: | |
types: [published] | |
env: | |
NODE_VERSION: 18 | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: check theme version against tag | |
run: | | |
THEME_VERSION=$(cat sass/style.scss | grep Version | sed -r 's/version: +//I') | |
V="v" | |
echo Version in style.scss: $THEME_VERSION | |
if [ "$V$THEME_VERSION" != "${{ github.ref_name }}" ]; then exit 1; fi | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install npm packages | |
run: npm ci | |
- name: Build CSS | |
run: npm run compile:build | |
- name: Build CSS-RTL | |
run: npm run compile:rtl | |
- name: Build JS | |
run: npm run build | |
- name: run install composer | |
run: composer install | |
- name: Make bundle | |
run: npm run bundle | |
- name: fail on fork | |
if: github.repository_owner != 'verdigado' | |
run: exit 1 | |
- name: Rename ZIP file | |
run: | | |
mv ../sunflower.zip sunflower-${{ github.ref_name }}.zip | |
- name: Upload Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "sunflower-${{ github.ref_name }}.zip" | |
allowUpdates: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Provide deploy_key | |
env: | |
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SSH_USER: 'github-ci' | |
SSH_HOST: 'wordpress05.gcms.verdigado.net' | |
run: | | |
mkdir "$HOME/.ssh" | |
echo "$DEPLOY_KEY" > "$HOME/.ssh/production.key" | |
chmod 600 "$HOME/.ssh/production.key" | |
cat >> ~/.ssh/config <<END | |
Host production | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/production.key | |
StrictHostKeyChecking no | |
END | |
- name: save version | |
run: echo ${{ github.ref_name }} > version.txt | |
- name: rsync zipfile, version and changelog | |
env: | |
PAGEID: 1952 | |
run: | | |
rsync -a sunflower-${{ github.ref_name }}.zip version.txt sunflower/changelog.html production:/var/www/updateserver/ | |
THEME_VERSION=$(cat version.txt | sed -e 's/^v//') | |
ssh production "cd /var/www && wp post get $PAGEID --field=content | sed -e 's/<version>[^<]*/<version>$THEME_VERSION/g' > /tmp/content-$PAGEID.txt" | |
ssh production "cd /var/www && wp post update $PAGEID - < /tmp/content-$PAGEID.txt && wp option update blogdescription 'Demoseite für das WordPress-Theme Sunflower $THEME_VERSION' --url=sunflower-theme.de/demo && wp option update blogname 'Sunflower $THEME_VERSION'" | |
mkdocs: | |
runs-on: ubuntu-latest | |
needs: build-deploy | |
steps: | |
- uses: actions/checkout@v4 | |
- name: mkdocs build | |
uses: Tiryoh/actions-mkdocs@v0 | |
with: | |
mkdocs_version: 'latest' # option | |
# mkdocs_version: '1.1' # option | |
# requirements: 'requirements.txt' # option | |
configfile: 'mkdocs/mkdocs.yml' # option | |
- name: Provide deploy_key | |
env: | |
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SSH_USER: 'github-ci' | |
SSH_HOST: 'wordpress05.gcms.verdigado.net' | |
run: | | |
mkdir "$HOME/.ssh" | |
echo "$DEPLOY_KEY" > "$HOME/.ssh/production.key" | |
chmod 600 "$HOME/.ssh/production.key" | |
cat >> ~/.ssh/config <<END | |
Host production | |
HostName $SSH_HOST | |
User $SSH_USER | |
IdentityFile ~/.ssh/production.key | |
StrictHostKeyChecking no | |
END | |
- name: save version | |
run: echo ${GITHUB_REF##*/} > version.txt | |
- name: rsync documentation | |
run: rsync -a --delete documentation production:/var/www/documentation/ |