merge dojo/main #15
Workflow file for this run
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: devcontainer | |
on: | |
push: | |
paths: | |
- ".devcontainer/**" | |
- ".github/workflows/devcontainer.yml" | |
- "!.devcontainer/devcontainer.json" | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest-4-cores | |
env: | |
DOCKER_TAG: latest | |
outputs: | |
tag_name: ${{ steps.release_info.outputs.tag_name }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Docker tag for release event | |
if: github.event_name == 'release' | |
run: | | |
echo "DOCKER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
echo "tag_name=$DOCKER_TAG" >> $GITHUB_OUTPUT | |
- name: Set Docker tag for push event | |
if: github.event_name == 'push' | |
run: | | |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c 1-7) | |
echo "DOCKER_TAG=$SHORT_SHA" >> $GITHUB_ENV | |
- name: Set outputs | |
id: release_info | |
run: | | |
echo "tag_name=${{ env.DOCKER_TAG }}" >> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: .devcontainer/Dockerfile | |
tags: ghcr.io/${{ github.repository }}-dev:latest,ghcr.io/${{ github.repository }}-dev:${{ env.DOCKER_TAG }} | |
build-args: | | |
VARIANT=bookworm | |
platforms: linux/amd64,linux/arm64 | |
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-dev:latest | |
propose-update-pr: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Update devcontainer.json | |
run: sed -i "s|ghcr.io/dojoengine/dojo-dev:[a-zA-Z0-9._-]*|ghcr.io/dojoengine/dojo-dev:${{ needs.build-and-push.outputs.tag_name }}|" .devcontainer/devcontainer.json | |
- name: Update github action devcontainers | |
run: | | |
for file in .github/workflows/*.yml; do | |
if [[ $file != ".github/workflows/devcontainer.yml" ]]; then | |
sed -i "s|ghcr.io/dojoengine/dojo-dev:[a-zA-Z0-9._-]*|ghcr.io/dojoengine/dojo-dev:${{ needs.build-and-push.outputs.tag_name }}|" "$file" | |
fi | |
done | |
- uses: peter-evans/create-pull-request@v5 | |
with: | |
# We have to use a PAT in order to trigger ci | |
token: ${{ secrets.CREATE_PR_TOKEN }} | |
title: "Update devcontainer image hash: ${{ needs.build-and-push.outputs.tag_name }}" | |
commit-message: "Update devcontainer image hash: ${{ needs.build-and-push.outputs.tag_name }}" | |
branch: bump-devcontainer | |
base: main | |
delete-branch: true |