updates #736
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_one | |
| on: push | |
| jobs: | |
| build_one: | |
| if: "!contains(github.event.head_commit.message, 'skip ci')" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push to docker | |
| env: | |
| DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| LP_T_CONSUMER_KEY: ${{ secrets.LP_T_CONSUMER_KEY }} | |
| LP_T_CONSUMER_SECRET: ${{ secrets.LP_T_CONSUMER_SECRET }} | |
| LP_T_OAUTH_SECRET: ${{ secrets.LP_T_OAUTH_SECRET }} | |
| LP_T_OAUTH_TOKEN: ${{ secrets.LP_T_OAUTH_TOKEN }} | |
| run: | | |
| set -x | |
| sudo rm /etc/localtime | |
| sudo ln -s /usr/share/zoneinfo/America/Toronto /etc/localtime | |
| docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD | |
| curl --silent --location --output ~/am-dapp --url https://github.com/forwardcomputers/bin/raw/main/am-dapp | |
| chmod +x ~/am-dapp | |
| GH_SHA=$( \ | |
| curl --silent --location --url https://api.github.com/repos/forwardcomputers/dockerfiles/commits | \ | |
| jq -r '.[0].sha' \ | |
| ) | |
| GH_APP=( $( \ | |
| curl --silent --location --url https://api.github.com/repos/forwardcomputers/dockerfiles/commits/"${GH_SHA}" | \ | |
| jq --raw-output '[.files | .[] | select( .status == "added" or .status == "modified" and ( ( .filename | contains(".github") | not ) or ( .filename | contains(".github") | not ) ) and ( .filename | contains("/") ) ) | .filename | split("/")[0]] | unique[]') \ | |
| ) | |
| for APP in "${GH_APP[@]}"; do | |
| ~/am-dapp build ${APP} | |
| ~/am-dapp push ${APP} | |
| ~/am-dapp readme | |
| done | |
| - name: Commit and push to github | |
| if: ${{ ! failure() }} | |
| run: | | |
| git config --local user.email "alim@forwardcomputers.com" | |
| git config --local user.name "Ali Mustakim" | |
| git add README.md | |
| git diff-index --quiet HEAD || git commit -a -m "github actions update" | |
| git push origin | |
| - name: Tweet on Failure | |
| if: ${{ failure() }} | |
| env: | |
| LP_T_CONSUMER_KEY: ${{ secrets.LP_T_CONSUMER_KEY }} | |
| LP_T_CONSUMER_SECRET: ${{ secrets.LP_T_CONSUMER_SECRET }} | |
| LP_T_OAUTH_SECRET: ${{ secrets.LP_T_OAUTH_SECRET }} | |
| LP_T_OAUTH_TOKEN: ${{ secrets.LP_T_OAUTH_TOKEN }} | |
| run: | | |
| # Code bits from - https://github.com/moebiuscurve/tweetExperiments/tree/master/curlTweets | |
| repo_name=$( echo "$GITHUB_REPOSITORY" | awk -F / '{ print $2 }' ) | |
| message="${repo_name} failed" | |
| message_string=$( echo -n "${message}" | sed -e s'/ /%2520/g' ) | |
| message_curl=$( echo -n "${message}" | sed -e s'/ /+/g' ) | |
| timestamp=$( date +%s ) | |
| nonce=$( date +%s%T | openssl base64 | sed -e s'/[+=/]//g' ) | |
| api_version="1.1" | |
| signature_base_string="POST&https%3A%2F%2Fapi.twitter.com%2F${api_version}%2Fstatuses%2Fupdate.json&oauth_consumer_key%3D${LP_T_CONSUMER_KEY}%26oauth_nonce%3D${nonce}%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D${timestamp}%26oauth_token%3D${LP_T_OAUTH_TOKEN}%26oauth_version%3D1.0%26status%3D${message_string}" | |
| signature_key="${LP_T_CONSUMER_SECRET}&${LP_T_OAUTH_SECRET}" | |
| oauth_signature=$( echo -n "${signature_base_string}" | openssl dgst -sha1 -hmac "${signature_key}" -binary | openssl base64 | sed -e s'/+/%2B/g' -e s'/\//%2F/g' -e s'/=/%3D/g' ) | |
| header="Authorization: OAuth oauth_consumer_key=\"${LP_T_CONSUMER_KEY}\", oauth_nonce=\"${nonce}\", oauth_signature=\"${oauth_signature}\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"${timestamp}\", oauth_token=\"${LP_T_OAUTH_TOKEN}\", oauth_version=\"1.0\"" | |
| result=$( curl -s -X POST "https://api.twitter.com/${api_version}/statuses/update.json" --data "status=${message_curl}" --header "Content-Type: application/x-www-form-urlencoded" --header "${header}" ) |