Update development.yml #35
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: Development CI/CD | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
development-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ github.repository_owner }}/palworld-dedicated-server | |
ghcr.io/${{ github.repository }} | |
tags: type=raw,value=dev | |
flavor: latest=false | |
- name: Get short SHA | |
id: slug | |
run: echo "GIT_SHORT_SHA7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> "$GITHUB_OUTPUT" | |
- name: Check README.md shield tag | |
id: check_shield_tag | |
run: | | |
if grep -q "readme-dev-blue" README.md; then | |
echo "The shield tag is already set to 'dev'. No update needed." | |
echo "update_required=false" >> "$GITHUB_OUTPUT" | |
else | |
echo "The shield tag is not set to 'dev'. Proceeding with the update." | |
echo "update_required=true" >> "$GITHUB_OUTPUT" | |
fi | |
shell: bash | |
- name: Update Required? | |
run: | | |
echo "Update required? '${{ steps.check_shield_tag.outputs.update_required }}'" | |
# Defines the readme version to the dev tag | |
- name: Update README.md | |
if: steps.check_shield_tag.outputs.update_required == 'true' | |
run: | | |
echo "Changing README.md version to 'dev'." | |
sed "s/readme-\(.*\)-blue/readme-dev-blue/g" README.md > temp.md | |
mv temp.md README.md | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git pull origin main | |
git add README.md | |
git commit -m "Update README.md for tag 'dev' [skip ci]" | |
git push origin main | |
- name: Checkout after README.md update | |
if: steps.check_shield_tag.outputs.update_required == 'true' | |
uses: actions/checkout@v4 | |
- name: Build and push | |
id: build_push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64 | |
push: true | |
tags: | | |
${{ steps.meta.outputs.tags }} | |
${{ secrets.DOCKER_USERNAME }}/palworld-dedicated-server:${{ steps.slug.outputs.GIT_SHORT_SHA7 }} | |
ghcr.io/${{ github.repository }}:${{ steps.slug.outputs.GIT_SHORT_SHA7 }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
enable-url-completion: true | |
repository: ${{ secrets.DOCKER_USERNAME }}/palworld-dedicated-server |