updating #1442
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
## Sends a slack message | |
## Docs: | |
## * https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges | |
## | |
name: "Slack - rec.gov - tours" | |
# on: | |
# # Push is for testing only to allow you to test this workflow without | |
# # a merge and just a push. | |
# push: | |
# pull_request: | |
# types: | |
# - closed | |
# on: | |
# Push is for testing only to allow you to test this workflow without | |
# a merge and just a push. | |
# push: | |
# pull_request: | |
# types: | |
# - closed | |
# branches: | |
# - main | |
## Schedule doc: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule | |
# schedule: | |
# - cron: '*/5 * * * *' | |
# # - cron: '30 5 * * 2,4' | |
env: | |
# SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }} | |
# Enable debug output | |
DEBUG: false | |
# Search 1 | |
FACILITY_ID_1: 251853 | |
TOUR_ID_1: 194 | |
YEAR_1: 2023 | |
MONTH_1: 08 | |
jobs: | |
send_slack: | |
# if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get site info | |
run: | | |
LOCAL_FACILITY_INFO_1=$(curl https://www.recreation.gov/api/ticket/facility/${{ env.FACILITY_ID_1 }}) | |
echo "FACILITY_NAME_1=$(echo $LOCAL_FACILITY_INFO_1 | jq -r .facility_name )" >> $GITHUB_ENV | |
- name: Run script | |
run: | | |
LOCAL_AVAILABLE_DATES_1=$(./recreation.gov/run.sh ${{ env.FACILITY_ID_1 }} ${{ env.TOUR_ID_1 }} ${{ env.YEAR_1 }} ${{ env.MONTH_1 }}) | |
# if the string is not empty | |
if [ -n "$LOCAL_AVAILABLE_DATES_1" ]; then | |
echo "Available dates found: ${{ env.FACILITY_NAME_1 }}" | |
echo "AVAILABLE_DATES_1=true" >> $GITHUB_ENV | |
echo "AVAILABLE_DATES_1_DATA=$(echo $LOCAL_AVAILABLE_DATES_1)" >> $GITHUB_ENV | |
else | |
echo "No available dates found: ${{ env.FACILITY_NAME_1 }}" | |
echo "AVAILABLE_DATES_1=false" >> $GITHUB_ENV | |
fi | |
echo "finished" | |
echo "FACILITY_INFO_1: ${{ env.FACILITY_INFO_1 }}" | |
## Doc: https://github.com/marketplace/actions/slack-send | |
- name: Post to Slack channel | |
if: env.AVAILABLE_DATES_1 == 'true' | |
id: slack1 | |
uses: slackapi/slack-github-action@v1.24.0 | |
with: | |
# Slack channel id, channel name, or user id to post message. | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
# You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs. | |
channel-id: 'C05B9LLPVD5' # sf-devops.slack.com - recreation-gov | |
slack-message: | | |
FACILITY_NAME: ${{ env.FACILITY_NAME_1 }} | |
TOUR_ID: ${{ env.TOUR_ID_1 }} | |
SEARCH DATE: ${{ env.YEAR_1 }}-${{ env.MONTH_1 }} | |
TOUR LINK: https://www.recreation.gov/ticket/${{ env.FACILITY_ID_1 }}/ticket/${{ env.TOUR_ID_1 }} | |
AVAILABLE_DATES: | |
${{ env.AVAILABLE_DATES_1_DATA }} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |