new-docker-image #1031
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: Update Docker Compose | |
on: | |
repository_dispatch: | |
types: [new-docker-image] | |
permissions: | |
contents: write | |
jobs: | |
update-docker-compose: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Get the event payload | |
id: get-payload | |
run: | | |
echo "TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV | |
- name: Read the current sinlessgames image tag from docker-compose.home.yml | |
id: read_compose_tag | |
run: | | |
current_image=$(grep 'image: sinless777/sinlessgames-ui' docker-compose.home.yml | awk -F: '{print $3}') | |
echo "CURRENT_IMAGE_TAG=${current_image}" >> $GITHUB_ENV | |
- name: Compare tags and update docker-compose.home.yaml if necessary | |
run: | | |
if [ "${{ env.CURRENT_IMAGE_TAG }}" != "${{ env.TAG }}" ]; then | |
echo "Updating docker-compose.home.yaml with new tag: ${{ env.TAG }}" | |
sed -i "s|image: sinless777/sinlessgames-ui:${{ env.CURRENT_IMAGE_TAG }}|image: sinless777/sinlessgames-ui:${{ env.TAG }}|" docker-compose.home.yml | |
else | |
echo "No update needed. Current tag ${{ env.CURRENT_IMAGE_TAG }} matches the desired tag (${{ env.TAG }})." | |
fi | |
cat docker-compose.home.yml | |
- name: Commit changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Sinless777" | |
if [ "${{ env.CURRENT_IMAGE_TAG }}" != "${{ env.TAG }}" ]; then | |
git pull origin | |
git add . | |
git commit -m "Update sinlessgames image tag to ${{ env.TAG }}" | |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/Sinless777/services-docker.git HEAD:main | |
fi |