Skip to content

Commit

Permalink
Merge pull request #1248 from tubone24/add_support
Browse files Browse the repository at this point in the history
Add support
  • Loading branch information
tubone24 committed Jan 15, 2023
2 parents 5738eab + 91480d9 commit 0b040d1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 58 deletions.
43 changes: 1 addition & 42 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,4 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM node:16.19.0

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# The node image comes with a base non-root 'node' user which this Dockerfile
# gives sudo access. However, for Linux, this user's GID/UID must match your local
# user UID/GID to avoid permission issues with bind mounts. Update USER_UID / USER_GID
# if yours is not 1000. See https://aka.ms/vscode-remote/containers/non-root-user.
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
#
# Verify git and needed tools are installed
&& apt-get -y install --no-install-recommends git iproute2 procps \
#
# Remove outdated yarn from /opt and install via package
# so it can be easily updated via apt-get upgrade yarn
&& rm -rf /opt/yarn-* \
&& rm -f /usr/local/bin/yarn \
&& rm -f /usr/local/bin/yarnpkg \
&& apt-get install -y --no-install-recommends curl apt-transport-https lsb-release \
#
# Install yarn
&& npm install -g yarn \
#
# [Optional] Update a non-root user to match UID/GID - see https://aka.ms/vscode-remote/containers/non-root-user.
&& if [ "$USER_GID" != "1000" ]; then groupmod node --gid $USER_GID; fi \
&& if [ "$USER_UID" != "1000" ]; then usermod --uid $USER_UID node; fi \
# [Optional] Add add sudo support for non-root user
&& apt-get install -y --no-install-recommends sudo \
&& echo node ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/node \
&& chmod 0440 /etc/sudoers.d/node \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /app
FROM ghcr.io/tubone24/blog/dev-container-base:latest
38 changes: 23 additions & 15 deletions .github/workflows/create_article_md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
run: |
echo "dateHyphen=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "dateISO=$(date '+%Y-%m-%dT%H:%M:%S%z')" >> $GITHUB_OUTPUT
BRANCH_NAME=${${{ inputs.title }}//" "/"-"}
TITLE="${{ inputs.title }}"
BRANCH_NAME=${TITLE//" "/"-"}
echo "titleHyphen=${BRANCH_NAME}" >> "${GITHUB_OUTPUT}"
echo "title=${{ inputs.title }}" >> "${GITHUB_OUTPUT}"
echo "description=${{ inputs.description }}" >> "${GITHUB_OUTPUT}"
Expand All @@ -31,21 +32,28 @@ jobs:
run: |
git config --local user.name GitHubActions
git remote set-url origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
- name: Create new draft Branch
- name: Create new draft articles
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout -b ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}
cp template/article_template.md src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ dateHyphen }}/${{ steps.create-meta-data.outputs.dateHyphen }}/g' ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ dateISO }}/${{ steps.create-meta-data.outputs.dateISO }}/g' ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ title }}/${{ steps.create-meta-data.outputs.title }}/g' ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ description }}/${{ steps.create-meta-data.outputs.description }}/g' ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
cat ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
git add -A
DIFF=`git diff --cached --numstat | wc -l`
if [ $DIFF -eq 0 ]; then
exit 0
fi
git commit -am 'GitHub Actions commit' --allow-empty
git push origin ${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}
sed -i 's/{{ dateHyphen }}/${{ steps.create-meta-data.outputs.dateHyphen }}/g' src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ titleHyphen }}/${{ steps.create-meta-data.outputs.titleHyphen }}/g' src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ dateISO }}/${{ steps.create-meta-data.outputs.dateISO }}/g' src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ title }}/${{ steps.create-meta-data.outputs.title }}/g' src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
sed -i 's/{{ description }}/${{ steps.create-meta-data.outputs.description }}/g' src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
cat src/content/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}.md
- name: Show GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
draft: true
branch: cms/blog/${{ steps.create-meta-data.outputs.dateHyphen }}-${{ steps.create-meta-data.outputs.titleHyphen }}
title: ${{ steps.create-meta-data.outputs.title }}
labels: ${{ steps.create-meta-data.outputs.label }}
assignees: ${{ github.triggering_actor }}
body: Automated changes by [create_article_md](https://github.com/tubone24/blog/actions/workflows/create_article_md.yml) GitHub action
2 changes: 1 addition & 1 deletion template/article_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: {{ dateHyphen }}/subscribers
slug: {{ dateHyphen }}/{{ titleHyphen }}
title: "{{ title }}"
date: {{ dateISO }}
description: {{ description }}
Expand Down

0 comments on commit 0b040d1

Please sign in to comment.