write-dockerfile #10
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: Write Dockerfile | |
on: | |
repository_dispatch: | |
types: [write-dockerfile] | |
jobs: | |
write_docker_file: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
ref: main | |
- name: Sleep 3 Second | |
run: | | |
sleep 3 | |
- name: Create Directory | |
run: mkdir -p ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.7' | |
- name: Install Jinja2 | |
run: | | |
python -m pip install --upgrade pip | |
pip install jinja2-cli | |
- name: Render Jinja template if builder is gradle | |
if: ${{ github.event.client_payload.builder == 'gradle' }} | |
run: | | |
echo '${{ github.event.client_payload.template_json }}' > template.json | |
jinja2 templates/dockerfile/templates/Dockerfile_use_gradle.template template.json -o ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }}/Dockerfile | |
mv template.json ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }} | |
- name: Render Jinja template if builder is node | |
if: ${{ github.event.client_payload.builder == 'node' }} | |
run: | | |
echo '${{ github.event.client_payload.template_json }}' > template.json | |
jinja2 templates/dockerfile/templates/Dockerfile_use_node.template template.json -o ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }}/Dockerfile | |
mv template.json ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }} | |
- name: Render Jinja template if builder is gradle | |
if: ${{ github.event.client_payload.builder == 'node_with_nginx' }} | |
run: | | |
echo '${{ github.event.client_payload.template_json }}' > template.json | |
jinja2 templates/dockerfile/templates/Dockerfile_use_node_with_nginx.template template.json -o ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }}/Dockerfile | |
mv template.json ./pipelines/${{ github.event.client_payload.environment }}/${{ github.event.client_payload.name }} | |
- name: Pull Commit | |
run: git pull | |
- name: Commit The New Image Reference | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "release :: Add Dockerfile for ${{ github.event.client_payload.name }}" | |
branch: main | |
repository: . | |
commit_user_name: XQUARE GitOps Bot | |
commit_user_email: [email protected] | |
commit_author: XQUARE GitOps Bot <[email protected]> |