Continuous Deployment #6
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: Continuous Deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Version of the data pack' | |
required: true | |
default: 'v1.0' | |
mc_version: | |
description: 'Minecraft version(s) the data pack runs in' | |
required: true | |
default: '1.20' | |
jobs: | |
create_data_pack: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3.5.3 | |
- name: Extract tag | |
id: tag_version | |
run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Find and replace uninstall file name | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "${file_name}" | |
replace: ${{ github.event.repository.name }}-${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-datapack.zip | |
regex: false | |
include: "**uninstall.mcfunction" | |
- name: Find and replace data pack version | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "${version}" | |
replace: ${{ github.event.inputs.tag }} | |
regex: false | |
# Check for existence of datapack and/or resourcepack folders. | |
- name: Check for data folder | |
id: check_datapack_folder | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "data" | |
- name: Check for assets folder | |
id: check_assets_folder | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "assets" | |
- name: Create data pack zip file | |
uses: montudor/action-zip@v0.1.0 | |
if: steps.check_datapack_folder.outputs.files_exists == 'true' | |
with: | |
args: zip -qq datapack.zip -r data pack.mcmeta pack.png LICENSE README.md | |
- name: Create asset pack zip file | |
uses: montudor/action-zip@v0.1.0 | |
if: steps.check_assets_folder.outputs.files_exists == 'true' | |
with: | |
args: zip -qq assetpack.zip -r assets pack.mcmeta pack.png LICENSE README.md | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.inputs.tag }} | |
release_name: Release ${{ github.event.inputs.tag }} | |
draft: false | |
prerelease: false | |
- name: Upload assetpack release asset | |
uses: actions/upload-release-asset@v1 | |
if: steps.check_assets_folder.outputs.files_exists == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./assetpack.zip | |
asset_name: ${{ github.event.repository.name }}-${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-resourcepack.zip | |
asset_content_type: application/zip | |
- name: Upload datapack release asset | |
uses: actions/upload-release-asset@v1 | |
if: steps.check_datapack_folder.outputs.files_exists == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./datapack.zip | |
asset_name: ${{ github.event.repository.name }}-${{ github.event.inputs.tag }}-mc${{ github.event.inputs.mc_version }}-datapack.zip | |
asset_content_type: application/zip |