Workflow file for this run
This file contains hidden or 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: Build and Push Docker Image on Release | |
| on: | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Check out the code | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # Update version in config.py | |
| - name: Update version in config.py | |
| run: | | |
| # Extract version from tag | |
| VERSION="${{ github.event.release.tag_name }}" | |
| # Update the BOT_VERSION in config.py (this change won't be committed) | |
| sed -i 's/BOT_VERSION = "v\.local"/BOT_VERSION = "'"$VERSION"'"/' src/config.py | |
| # Show the change for debugging | |
| echo "Updated config.py with version $VERSION" | |
| grep BOT_VERSION src/config.py | |
| # Log in to Docker Hub | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| # Set up Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| # Get repository variables | |
| - name: Set Docker image variables | |
| run: | | |
| echo "DOCKER_IMAGE=${{ vars.DOCKER_IMAGE }}" >> $GITHUB_ENV | |
| # Build and Push Docker Image | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| ${{ env.DOCKER_IMAGE }}:latest | |
| ${{ env.DOCKER_IMAGE }}:${{ github.event.release.tag_name }} | |
| update-addon: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| # Step 2: Get the version tag from the release and set it as an environment variable | |
| - name: Get version tag from the release | |
| run: | | |
| echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
| # Step 3: Update version in config.yaml | |
| - name: Update version in config.yaml | |
| run: | | |
| sed -i "s/version: .*/version: ${{ env.VERSION }}/" octopus_minmax_bot_addon/config.yaml | |
| # Step 4: Copy README.md to octopus_minmax_bot_addon | |
| - name: Copy README.md to octopus_minmax_bot_addon | |
| run: cp README.md octopus_minmax_bot_addon/README.md | |
| # Step 5: Add release notes to CHANGELOG.md | |
| - name: Add release notes to CHANGELOG.md | |
| run: | | |
| RELEASE_NOTES=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.VERSION }}" | jq -r '.body') | |
| RELEASE_TITLE=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ env.VERSION }}" | jq -r '.name') | |
| echo -e "## ${{ env.VERSION }} - ${RELEASE_TITLE}\n${RELEASE_NOTES}\n" | cat - octopus_minmax_bot_addon/CHANGELOG.md > temp && mv temp octopus_minmax_bot_addon/CHANGELOG.md | |
| # Step 6: Create Pull Request | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v3 | |
| with: | |
| title: "Update Addon Configuration to ${{ env.VERSION }}" | |
| body: "This PR updates the addon configuration to the tagged release version and includes changes to README and CHANGELOG." | |
| base: main | |
| branch: update-addon-config-${{ env.VERSION }} | |
| token: ${{ secrets.GITHUB_TOKEN }} |